You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Owning entity has two members of same type, both marked with OwnsOne. Without use of InMemoryDatabaseRoot entities can be saved, but with use - and no other changes two unexpected behaviors occur
unset (null) property A gets the value of B
if both are in fact set to different object, ef throws claiming duplicate key
Owning entity has two members of same type, both marked with
OwnsOne
. Without use ofInMemoryDatabaseRoot
entities can be saved, but with use - and no other changes two unexpected behaviors occurSteps to reproduce
Test code includes an InMemoryDbContext with a parameter controlling whether a db root should be used or not:
Finally, two tests which fail or pass only depending on the
useRoot
boolean:The whole project is attached to this issue. ef_bug.zip
The first test fails because
newEntity.OwnedA
that is supposed to stay null has magically gotten the value ofOwnedB
.Second test fails with an exception from SaveChangesAsync()
The change tracker shows both instances indeed have a key 1, but only when db root is not used the save will succeed:
Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.InMemory 3.1.3
Target framework: .NET Core 3.1
Operating system: Windows 10 1909 build 18363.815
IDE: Visual Studio 2019 16.5.4
XUnit 2.4.1, Shouldly 3.0.2
The text was updated successfully, but these errors were encountered: