Entity Framework Core updating tables in navigation fields
so in efcore lets say i have an entity Foo and Baz:
my question is if i try to update Foo how can i efcore to only update the FooId property in Baz
if i pass
Foo { Baz { Id: 1, FooId: 2 } }
, i don't want Baz.SomeOtherProp
to be null i just want it to stay the same3 Replies
You either do a roundtrip to get
Baz
first, or you use ExecuteUpdate
.Alternatively, if you have
Baz
as a set on your dbcontext, you can instantiate a new instance of Baz
and attach it, make your modification, then use SaveChanges()
like normal.
Doing it like this can be useful if you have multiple entities to modify with unique valuesUnknown User•4w ago
Message Not Public
Sign In & Join Server To View