Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ChangeTracker.Entries Method

Definition

Namespace:
Microsoft.EntityFrameworkCore.ChangeTracking
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v1.0.6
Package:
Microsoft.EntityFrameworkCore v1.1.6
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v2.0.3
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
Entries()

Returns an EntityEntry for each entity being tracked by the context. The entries provide access to change tracking information and operations for each entity.

Entries<TEntity>()

Gets an EntityEntry for all entities of a given type being tracked by the context. The entries provide access to change tracking information and operations for each entity.

Entries()

Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs

Returns an EntityEntry for each entity being tracked by the context. The entries provide access to change tracking information and operations for each entity.

public virtual System.Collections.Generic.IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry> Entries();
abstract member Entries : unit -> seq<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry>
override this.Entries : unit -> seq<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry>
Public Overridable Function Entries () As IEnumerable(Of EntityEntry)

Returns

An entry for each entity being tracked.

Remarks

Consider using the methods of Local for faster lookup of tracked entities by key, foreign key, or property value.

This method calls DetectChanges() to ensure all entries returned reflect up-to-date state. Since detecting changes can be slow, consider temporarily setting AutoDetectChangesEnabled to prevent detecting changes in situations where the state is known to be up-to-date.

Note that modification of entity state while iterating over the returned enumeration may result in an InvalidOperationException indicating that the collection was modified while enumerating. To avoid this, create a defensive copy using ToList<TSource>(IEnumerable<TSource>) or similar before iterating.

See EF Core change tracking for more information and examples.

Applies to

Entries<TEntity>()

Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs
Source:
ChangeTracker.cs

Gets an EntityEntry for all entities of a given type being tracked by the context. The entries provide access to change tracking information and operations for each entity.

public virtual System.Collections.Generic.IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>> Entries<TEntity>() where TEntity : class;
abstract member Entries : unit -> seq<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity>> (requires 'Entity : null)
override this.Entries : unit -> seq<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity>> (requires 'Entity : null)
Public Overridable Function Entries(Of TEntity As Class) () As IEnumerable(Of EntityEntry(Of TEntity))

Type Parameters

TEntity

The type of entities to get entries for.

Returns

An entry for each entity of the given type that is being tracked.

Remarks

Consider using the methods of Local for faster lookup of tracked entities by key, foreign key, or property value.

This method calls DetectChanges() to ensure all entries returned reflect up-to-date state. Since detecting changes can be slow, consider temporarily setting AutoDetectChangesEnabled to prevent detecting changes in situations where the state is known to be up-to-date.

Note that modification of entity state while iterating over the returned enumeration may result in an InvalidOperationException indicating that the collection was modified while enumerating. To avoid this, create a defensive copy using ToList<TSource>(IEnumerable<TSource>) or similar before iterating.

See EF Core change tracking for more information and examples.

Applies to


Feedback

Was this page helpful?