Unable to update Foreign Key in Entity Framework 6

后端 未结 4 1367
迷失自我
迷失自我 2020-12-17 03:01

I am trying to do a simple update to the foreign key but the script never get sent over.

Here is the code I am using:

using (var db = new MyContext()         


        
4条回答
  •  没有蜡笔的小新
    2020-12-17 03:43

    Basically this happens because EntryState.Modified just looks for scalar properties (primitive types) and with independent association (your case) you don't have it.

    There is a several ways to achieve this, @Yuliam has pointed some of them and here you can find more.

提交回复
热议问题