为了账号安全,请及时绑定邮箱和手机立即绑定

使用 uint 作为主键的代码优先方法

使用 uint 作为主键的代码优先方法

C#
德玛西亚99 2022-10-23 15:56:52
我在 MVC 中使用代码优先方法来生成表。我试图使我的 Employee 类的主键成为 uint 以防止负值,但显然,我总是遇到异常。是否有用于 int 类型的装饰代码以防止负数或允许 uint 作为主键的解决方法?public class Employee{     [Key]     [Column(Order = 0)]     public uint EmployeeId { get; set; }     public string FirstName { get; set; }     public string LastName { get; set; }     public decimal Salary { get; set; }}
查看完整描述

1 回答

?
慕妹3146593

TA贡献1820条经验 获得超9个赞

看看这个

除此之外,uint 不符合 CLS,所以一般不推荐使用


查看完整回答
反对 回复 2022-10-23
  • 1 回答
  • 0 关注
  • 101 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号