Implementation details for EF Core change tracking. Use when changing InternalEntityEntry, ChangeDetector, SnapshotFactoryFactory, or related entity state, snapshot, or property accessor code.
64
81%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Manages entity states and detects changes for SaveChanges().
StateManager — owns tracked entries, identity/reference maps, fixup, cascades, notifications, and changed countsInternalEntryBase and derived classes — own per-entry state, flags, values, snapshots, and ordered state transitionsChangeDetector — compares current values with baselines and reports changes through entry mutation APIsSnapshotFactoryFactory subclasses — create passive original- and relationship-value baselinesIdentityMap — permits one active entry per key; shared identity pairs a replacement with the prior Deleted entryPropertyAccessorsFactory, ClrPropertyGetterFactory and ClrPropertySetterFactory compile property accessors for efficient snapshotting and change detection
indices parameter specify element at each complex collection depthSetPropertyModified() to keep property flags and entity state consistent.SetEntityState() validates values, updates flags and complex entries, changes state, then runs manager bookkeeping hooks.SharedIdentityEntry is the invariant that distinguishes an old deleted entry from its replacement with the same identity. When attaching a replacement graph, a deleted nested entry should be reconsidered only when its source entry has a replacement; do not broadly process every deleted node. Likewise, cascading from the old replaced principal must not delete dependents that belong to the replacement graph. Keep synchronous and asynchronous graph-attach paths equivalent and preserve unrelated values in replacement tests so they isolate the identity transition.
Unit tests: test/EFCore.Tests/ChangeTracking/. Functional tests: test/EFCore.Specification.Tests/GraphUpdates/.
| Pitfall | Solution |
|---|---|
| State-based checks treat every Added/Deleted entry as a replacement | Scope replacement behavior through SharedIdentityEntry and the graph source |
DetectChanges() identifies modified properties via snapshot comparisondotnet/efcore
c0f183b
Also appears in
last in sync Sep 22, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.