Entity Framework Tracking vs. No-Tracking No-tracking queries

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

  • No tracking queries are useful when the results are used in a read-only scenario
  • They are quicker to execute because there is no need to setup change tracking information

Example :

using (var context = new BookContext())
{
    var books = context.Books.AsNoTracking().ToList();
}

With EF Core 1.0 you are also able to change the default tracking behavior at the context instance level.

Example :

using (var context = new BookContext())
{
    context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

    var books = context.Books.ToList();
}


Got any Entity Framework Question?