liveBook · Manning

Snapshot

As explained in ASP.NET Core in Action, 3e

A tracking snapshot is a stored set of an entity's property values used to compare its original and current state.

A tracking snapshot stores the property values of an entity when EF Core loads it. When SaveChangesAsync runs, EF Core compares the current entity with that snapshot. section 12.4.4

The comparison determines the database update:

  • Changed properties are included in the generated UPDATE statement. section 12.4.4
  • Unchanged properties are ignored, avoiding unnecessary column writes. section 12.4.4
  • The normal workflow reads a tracked entity, changes its properties, and calls SaveChangesAsync(). section 12.4.4
Figure 12.14 Updating an entity involves three steps: read the entity using EF Core, update the properties of the entity, and call SaveChangesAsync() on the DbContext to generate the SQL to update the correct rows in the database.
CH12_F14_Lock3

Follow the three-step update flow from reading an entity through generating SQL for the correct rows. section 12.4.4

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains snapshot creation and comparison, but defers alternative tracking mechanisms, disabling tracking, and inspection details.
Examples
Uses a tracked Recipe entity whose changed properties become part of an UPDATE statement.
What it assumes
Assumes familiarity with loading entities and calling SaveChangesAsync while explaining change comparison directly.
What you can do after
Evaluate/understand why EF Core updates selected columns instead of every entity property.
How it connects
Connects change tracking with Entity Framework Core, DbContext, SaveChangesAsync, and SQL UPDATE statements.

Also explained in

Compare how 11 books explain snapshot →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.