Note

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

Access to this page requires authorization. You can try .

EntityFrameworkQueryableExtensions.AsNoTrackingWithIdentityResolution<TEntity> Method

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v10.0.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
Source:
EntityFrameworkQueryableExtensions.cs
Source:
EntityFrameworkQueryableExtensions.cs
Source:
EntityFrameworkQueryableExtensions.cs
Source:
EntityFrameworkQueryableExtensions.cs
Source:
EntityFrameworkQueryableExtensions.cs
Source:
EntityFrameworkQueryableExtensions.cs

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.

The change tracker will not track any of the entities that are returned from a LINQ query. If the entity instances are modified, this will not be detected by the change tracker and SaveChanges() will not persist those changes to the database.

public static System.Linq.IQueryable<TEntity> AsNoTrackingWithIdentityResolution<TEntity>(this System.Linq.IQueryable<TEntity> source) where TEntity : class;
static member AsNoTrackingWithIdentityResolution : System.Linq.IQueryable<'Entity (requires 'Entity : null)> -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function AsNoTrackingWithIdentityResolution(Of TEntity As Class) (source As IQueryable(Of TEntity)) As IQueryable(Of TEntity)

Type Parameters

TEntity

The type of entity being queried.

Parameters

source
IQueryable<TEntity>

The source query.

Returns

IQueryable<TEntity>

A new query where the result set will not be tracked by the context.

Exceptions

source is null.

Remarks

Disabling change tracking is useful for read-only scenarios because it avoids the overhead of setting up change tracking for each entity instance. You should not disable change tracking if you want to manipulate entity instances and persist those changes to the database using SaveChanges().

Identity resolution will be performed to ensure that all occurrences of an entity with a given key in the result set are represented by the same entity instance.

The default tracking behavior for queries can be controlled by QueryTrackingBehavior.

See No-tracking queries in EF Core for more information and examples.

Applies to


Feedback

Was this page helpful?