Entity Framework Creating new data rows during db.SaveChanges()

前端 未结 1 370
有刺的猬
有刺的猬 2020-12-12 01:22

Creating an AngularJS application based off of this tutorial: http://jphoward.wordpress.com/2013/01/04/end-to-end-web-app-in-under-an-hour/

Classes:

         


        
相关标签:
1条回答
  • 2020-12-12 01:34
    public class Todo
    {
        public int ID { get; set; }
    
        //Foreign key
        public int StatusID { get; set; } //<====Add this line
    
        public virtual Status Status { get; set; }
    }
    

    When you post your data update the foreign key property,not the navigational property

    Also ,check this: Why Does Entity Framework Reinsert Existing Objects into My Database? http://msdn.microsoft.com/en-us/magazine/dn166926.aspx

    0 讨论(0)
提交回复
热议问题