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.
- Retrieve data from the database.
- Update some properties on some objects.
- 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.
- Keep a copy of each object’s original state and compare it with all loaded objects when saving updates to the database.
- 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.
Code for most posts is available on my GitHub account.