📜  实体框架 ID 不自动递增 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:09.891000             🧑  作者: Mango

代码示例1
Use [Key, DatabaseGenerated(DatabaseGeneratedOption.None)] annotation on Id field

public class Item 
{
    [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
    [Required]
    public Guid Id { get; set; }
    public string Name { get; set; }
}