EntityType 'ApplicantPosition' has no key defined

后端 未结 4 632
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 05:36

When running my first asp.net mvc application I got this error I thought that entity framework automatically would create the keys of column names that end with Id? isnt it

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-13 06:23

    You can add the [Key] atributte to the property ApplicantId or do it via Fluent API overriding OnModelCreating method DbContext

    modelBuilder.Entity().HasKey(p => p.ApplicantId);
    

提交回复
热议问题