網站首頁 編程語言 正文
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Web; namespace MyFirstMvcApp.Models { ////// 登錄記錄 /// public class LoginRecordInfo { ////// 登錄的郵件地址(主鍵) /// [Key,Column(Order=1)] public string Email { get; set; } ////// 登錄的客戶端IP /// public string LoginHostIP { get; set; } ////// 登錄的客戶端主機名 /// public string LoginHostName { get; set; } ////// 登錄時間(主鍵) /// [Key,Column(Order=2)] public DateTime LoginTime { get; set; } } }
使用特性Key和Column設置復合主鍵,Key表示字段是主鍵,Order用來設置主鍵的順序。使用Key和Column需要添加命名空間:
- Key的命名空間:System.ComponentModel.DataAnnotations;
- Column的命名空間:System.ComponentModel.DataAnnotations.Schema;
原文鏈接:https://www.cnblogs.com/dotnet261010/p/7275510.html
相關推薦
- 2023-10-11 hutool工具類 | huTool的基本使用
- 2023-06-13 C語言中如何通過指針參數返回值_C 語言
- 2024-03-22 【IDEA】成功解決導入配置文件處理器spring-boot-configuration-proce
- 2023-06-13 C++?ncnn模型驗證精度實現代碼_C 語言
- 2023-01-17 使用matplotlib繪制熱圖(heatmap)全過程_python
- 2022-01-10 npm一個錯誤 npm ERR code ENOENT npm ERR syscall open
- 2022-07-14 設置Redis最大占用內存的實現_Redis
- 2024-04-05 springboot注冊攔截器與返回統一標準響應格式
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支