Disabling identity (auto-incrementing) on integer primary key using code first

后端 未结 7 1324
孤街浪徒
孤街浪徒 2020-12-01 10:13

I am using code first approach in a ASP.NET MVC 3 application and all integer primary keys in models (public int Id { get; set; }) are by default configured as

相关标签:
7条回答
  • 2020-12-01 11:02

    Use these data annotation options:

    • [System.ComponentModel.DataAnnotations.KeyAttribute()]
    • [System.ComponentModel.DataAnnotations.DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.None)]
    0 讨论(0)
提交回复
热议问题