ChangeTracker retained entity references after DbContext disposal in EF Core 7.0.0
0 reputation · 24 Jan 2020, 02:03 UTC
EF Core 7.0.0 ChangeTracker behavior is documented as retaining entity entries after DbContext disposal, leading to memory growth with repeated context lifetimes. The issue is reported as fixed in EF Core 7.0.1 by clearing internal state on disposal.
The default for AutoDetectChangesEnabled remains enabled in EF Core 7.0, which simplifies change tracking but can add overhead for large read-only queries. There is no announced plan to change this default in upcoming releases.
For applications that create short-lived DbContext instances with large tracking sets, the interaction between disposal clearing and automatic change detection is relevant.
What is the current design stance on keeping AutoDetectChangesEnabled enabled by default given read-heavy performance considerations? Is the ChangeTracker clearing implemented in 7.0.1 considered sufficient for all disposal paths? Are there documented guidelines for opting out of automatic detection without affecting update scenarios?