Entity Framework Foreign Key Inserts with Auto-Id

前端 未结 2 916
野趣味
野趣味 2021-02-09 04:42

I have 2 Entities User and User_Profile (one to one relationship). I have linked them as follows:

public class User
{
   [Key]   
   [ForeignKey(\"user_profile\"         


        
2条回答
  •  梦谈多话
    2021-02-09 04:59

    You have to set the StoreGeneratedPattern attribute to Identity in your .edmx file to let the framework know the field is generated by the database. This link might help...

    Autonumber with Entity Framework

提交回复
热议问题