網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
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; } ////// 登錄的客戶端主機(jī)名 /// public string LoginHostName { get; set; } ////// 登錄時(shí)間(主鍵) /// [Key,Column(Order=2)] public DateTime LoginTime { get; set; } } }
使用特性Key和Column設(shè)置復(fù)合主鍵,Key表示字段是主鍵,Order用來(lái)設(shè)置主鍵的順序。使用Key和Column需要添加命名空間:
- Key的命名空間:System.ComponentModel.DataAnnotations;
- Column的命名空間:System.ComponentModel.DataAnnotations.Schema;
原文鏈接:https://www.cnblogs.com/dotnet261010/p/7275510.html
相關(guān)推薦
- 2022-06-02 React中的Props類型校驗(yàn)和默認(rèn)值詳解_React
- 2022-08-16 Hive常用日期格式轉(zhuǎn)換語(yǔ)法_數(shù)據(jù)庫(kù)其它
- 2022-04-12 詳解pyqt中解決國(guó)際化tr()函數(shù)不起作用的問(wèn)題_python
- 2023-07-24 uniapp開發(fā) h5和小程序 拖動(dòng)懸浮按鈕
- 2022-06-28 C#基于自定義事件EventArgs實(shí)現(xiàn)發(fā)布訂閱模式_C#教程
- 2022-08-27 C#使用百度Ueditor富文本框?qū)崿F(xiàn)上傳文件_C#教程
- 2022-03-17 .net?程序通過(guò)?crontab?無(wú)法啟動(dòng)手動(dòng)執(zhí)行腳本啟動(dòng)的方法_實(shí)用技巧
- 2022-03-19 Docker?rocketmq部署的實(shí)現(xiàn)示例_docker
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支