We have a scenario in .Net Core API to Soft Delete Principal entity and all its dependent entities So We just loaded the dependent entities to include only Active dependent entities with Include(), set the Active = false and update with '''SavesChanges()'''. This part of logic is working fine. The problem is on Unit Test Part. We have configured DbContext to use In Memory Seed data, so it is not filtering dependent entities as per logic due to shared context. It works fine if We add AsNoTracking(), however in that case we are not able to update the relationships.