https://stackoverflow.com/questions/25417849/unable-to-update-foreign-key-in-entity-framework-6
Basically this happens because EntryState.Modified just looks for scalar properties (primitive types) and with independent association (your case) you don't have it.
GraphDiff
using (var context = new Context())
{
var customer = new Customer()
{
Id = 12503,
Name = "Jhon Doe",
City = new City() { Id = 8, Name = "abc" }
};
context.UpdateGraph(customer, map => map.AssociatedEntity(p => p.City));
context.Configuration.AutoDetectChangesEnabled = true;
context.SaveChanges();
}
我替你at去
最后一个没at到
大侠,瞅瞅问题啊
好久没用了,我有空试试,你用版本是什么?
6.4
找了个库,大概是解决了,会长
@猝不及防: 赞