AsNoTracking with identity resolution now available in Entity Framework Core 5.0

AsNoTracking() has been around in Entity Framework for a while. Its ideal to use when pulling back a collection of items which won’t be updated (a listing page for example) as it gives a little performance boost in these cases.

The default behaviour for AsNoTracking() is not to perform identity resolution. This means if your query returns 4 books and their authors, you’ll get 8 instances in total even if 2 books have the same author.

In Entity Framework Core 5.0 you can use AsNoTrackingWithIdentityResolution() to not track entities but still perform identity resolution so you won’t have duplicate instances.

The usage is the same as AsNoTracking()…


To enable identity resolution with no tracking queries EF Core uses a mini or stand-alone change tracker in the background which goes out of scope and is garbage collected as soon as the query results have been materialized.

Note… AsNoTrackingWithIdentityResolution() is a little slower than AsNoTracking() but still quicker than regular queries which utilize full change tracking.

2 thoughts on “AsNoTracking with identity resolution now available in Entity Framework Core 5.0”

  1. Cool thing, as some things got broken when updating from 2.2 to 3.1, now we can pass by the 3.1 step and move to 5 with just this renaming

Leave a Reply

Your email address will not be published. Required fields are marked *