Change tracking in EF Core

A database context in EF Core tracks the state of each entity it knows about[1]. It can "know" about the entity if

In a call to _context.SaveChanges() (or SaveChangesAsync()) it will call DetectChanges() (unless it's been disabled via config, in which case you have to do it yourself), creating the SQL to INSERT, UPDATE and DELETE as needed.

Viewing the changes in an EntityFramework change tracker:

_context.ChangeTracker.Entries()

you can use LINQ to further filter (by entity type, etc)


  1. ChangeTracker Class (Microsoft.EntityFrameworkCore.ChangeTracking) | Microsoft Learn ↩︎