EF Code First Change Tracking

Change tracking is a central concept for every Object-Relational Mapper, including Entity Framework. When doing updates to objects the normal work flow with Entity Framework has three steps.

  1. Retrieve data from the database.
  2. Update some properties on some objects.
  3. Save the updates to the database.

In the third step Entity Framework has to find out what properties on what objects were changed. There are two basic strategies to accomplish this.

  1. Keep a copy of each object’s original state and compare it with all loaded objects when saving updates to the database.
  2. Have a mechanism where the object context gets notified of changes to entity objects.
Software Development is a Job – Coding is a Passion

I'm Anders Abel, an independent systems architect and developer in Stockholm, Sweden.

profile for Anders Abel at Stack Overflow, Q&A for professional and enthusiast programmers

Code for most posts is available on my GitHub account.

Popular Posts

Archives

Series

Powered by WordPress with the Passion for Coding theme.