dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.66k stars 3.16k forks source link

How to fix up navigation collection without reloading? #30147

Open andre9349 opened 1 year ago

andre9349 commented 1 year ago

Hello. I have two navigation collections contains common entity inside. Atter I reloaded one of them, other navigation collection sill contains detached entity. I tried to fix it using ChangeTracker.DetectChanges() method, but unsuccessfully. How can I replace new entity in other collection without querying database? RefreshDetachedIssueSample.zip

ajcvickers commented 1 year ago

This looks like a bug. The navigation for the other relationship is still holding on to the detached entity, rather than it being removed.