使用uint作为主键的Code First方法

问题描述 投票:0回答:1

我在MVC中制作代码优先方法来生成表。我试图让我的Employee类的主键是防止负值,但显然,我总是得到一个例外。是否有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; }
}
c# entity-framework code-first uint
1个回答
1
投票

看看this

除此之外,uint不是CLS compliant,因此通常不建议使用

© www.soinside.com 2019 - 2024. All rights reserved.