EntityFrameworkQueryableExtensions.AsNoTracking<TEntity>(IQueryable<TEntity>) Method


Returns a new query where the change tracker will not track any of the entities that are returned. 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.

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().

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

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

Type Parameters


The type of entity being queried.



The source query.



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

Applies to