Using Entity Framework Code First CTP5, how do I create a primary key column that are INTs and are not identity columns

后端 未结 3 1698
盖世英雄少女心
盖世英雄少女心 2020-12-17 08:11

Using Entity Framework Code First CTP5, how do I create a primary key column that are INTs and are not identity columns

Preferably not using attributes.

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 08:38

    Small Change

    public class User
    {
    
      [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
    
      public int ID { get; set; }
    
      // Rest of the code
    }
    

提交回复
热议问题