OpenParable
Skip to content
← Back to skills

Change Tracking

Development
change-tracking

Change Tracking is an Agent Skill for development published in the dotnet/dotnet repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Implementation details for EF Core change tracking. Use when changing InternalEntityEntry, ChangeDetector, SnapshotFactoryFactory, or related entity state, snapshot, or property accessor code.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/dotnet/dotnet/blob/HEAD/src/efcore/.agents/skills/change-tracking/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/change-tracking, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Change Tracking

Manages entity states and detects changes for SaveChanges().

Core Components

  • StateManager — central engine, identity maps, tracks all entities
  • InternalEntityEntry — per-entity state, property flags, snapshots
  • SnapshotFactoryFactory subclasses build snapshot factories for change detection
  • PropertyAccessorsFactory, ClrPropertyGetterFactory and ClrPropertySetterFactory compile property accessors for efficient snapshotting and change detection
    • Ordinals in indices parameter specify element at each complex collection depth

Testing

Unit tests: test/EFCore.Tests/ChangeTracking/. Functional tests: test/EFCore.Specification.Tests/GraphUpdates/.

Common Pitfalls

PitfallSolution
There is a failure when there is shared identity entry (Added and Deleted)Add code that checks SharedIdentityEntry

Validation

  • DetectChanges() identifies modified properties via snapshot comparison
  • Setting original values marks properties as modified or unchanged based on comparison with current values