Skip to main content

change-tracking

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

소스 정보

저장소
dotnet/efcore
최근 소스 활동
2026년 10월 8일 18:29
감지된 SKILL.md 언어
영어
스타
14,795
포크
3,435

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
change-tracking
description
Implementation details for EF Core change tracking. Use when changing InternalEntityEntry, ChangeDetector, SnapshotFactoryFactory, or related entity state, snapshot, or property accessor code.
user-invocable
false
# Change Tracking Manages entity states and detects changes for `SaveChanges()`. ## Core Components - `StateManager` — owns tracked entries, identity/reference maps, fixup, cascades, notifications, and changed counts - `InternalEntryBase` and derived classes — own per-entry state, flags, values, snapshots, and ordered state transitions - `ChangeDetector` — compares current values with baselines and reports changes through entry mutation APIs - `SnapshotFactoryFactory` subclasses — create passive original- and relationship-value baselines - `IdentityMap` — permits one active entry per key; shared identity pairs a replacement with the prior `Deleted` entry - `PropertyAccessorsFactory`, `ClrPropertyGetterFactory` and `ClrPropertySetterFactory` compile property accessors for efficient snapshotting and change detection - Ordinals in `indices` parameter specify element at each complex collection depth ## Change Detection - Snapshot and notification strategies both call `SetPropertyModified()` to keep property flags and entity state consistent. - `SetEntityState()` validates values, updates flags and complex entries, changes state, then runs manager bookkeeping hooks. ## Shared-Identity Replacement `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. ## Testing Unit tests: `test/EFCore.Tests/ChangeTracking/`. Functional tests: `test/EFCore.Specification.Tests/GraphUpdates/`. ## Common Pitfalls | Pitfall | Solution | |---------|----------| | State-based checks treat every Added/Deleted entry as a replacement | Scope replacement behavior through `SharedIdentityEntry` and the graph source | ## Validation - `DetectChanges()` identifies modified properties via snapshot comparison - Setting original values marks properties as modified or unchanged based on comparison with current values
GitHub에서 보기