EF Core模型设置主键自增
提问
如何EF Core模型设置主键自增
回答
Microsoft.AspNetCore.Identity.EntityFrameworkCore
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
参考
https://www.quarkbook.com/?p=561
https://learn.microsoft.com/zh-cn/ef/core/modeling/generated-properties?tabs=data-annotations#primary-keys