liveBook · Manning

Change tracking

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

Change tracking is the process of recording entity instances and detecting changes to their properties for persistence.

Change tracking records the state of loaded entities so persistence can detect which properties changed. EF Core snapshots an entity's property values, compares them when SaveChanges() runs, and includes only changed properties in the generated UPDATE statement. section 12.4.4

Updating a recipe

RecipeService loads a recipe, updates its Name and TimeToCook properties, and calls SaveChangesAsync(). EF Core determines which values differ from the tracking snapshot and generates the corresponding SQL update.

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

How deep it goes
Explains snapshots and comparison during SaveChanges(), but defers alternative tracking mechanisms and configuration details.
Examples
Uses a RecipeService example that loads a recipe, changes properties, and saves it asynchronously.
What it assumes
Assumes EF Core entities and DbContext while explaining tracking behavior through a recipe update.
What you can do after
Apply it via EF Core to update only changed properties on a tracked entity.
How it connects
Connects EF Core, DbContext, entities, SaveChanges(), and SQL UPDATE statements.

Also explained in

Compare how 2 books explain change tracking →

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.