You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call stack refers to snapshot change tracking. By default, EF creates a snapshot of every entity's property values when it is first tracked by a DbContext instance. The values stored in this snapshot are then compared against the current values of the entity in order to determine which property values have changed. And when querying EF uses identity resolution, so only one instance is created for a given related entity.
There are two common optimizations for this:
If the entities don't need to be tracked, i.e. they aren't going to be modified and then persisted with SaveChanges, then you can add .AsNoTracking() to the query, however it will no longer use identity resolution and you can get duplicate instances
Otherwise, the entity types can implement INotifyPropertyChanging and INotifyPropertyChanged interfaces to avoid the need for a snapshot when tracking. Or use Trackable Entities to also make it easier to work with disconnected entities.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: f988f508-f5be-9961-830d-aa569adfcce9
Version Independent ID: 823ce300-dcb9-b51d-fe4b-5bb4625a8126
55 minutes into 10-20-2021 EF standup
have
@AndriySvyryd
review what I write.The call stack refers to snapshot change tracking. By default, EF creates a snapshot of every entity's property values when it is first tracked by a DbContext instance. The values stored in this snapshot are then compared against the current values of the entity in order to determine which property values have changed. And when querying EF uses identity resolution, so only one instance is created for a given related entity.
There are two common optimizations for this:
INotifyPropertyChanging
andINotifyPropertyChanged
interfaces to avoid the need for a snapshot when tracking. Or use Trackable Entities to also make it easier to work with disconnected entities.Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: