Entity Framework Change Tracking

Aug 27 2009

I needed to know how the Entity Framework does its change tracking, so I wrote a simple test to see what’s happening. Since we only needed to know what happened when you modify a property on an entity, I focused on that aspect (and not how deleting entities is tracked, for example).

Anyway: my conclusions… It seems that the Entity Framework sets the EntityState of an entity to Modified anytime you change a property. It does not matter what value you put in it.

To put this in a small list. The Modified state appears…

  • … when you assign a different value (obviously)
  • … when you assign a different value and then assign the previous value
  • … when you assign the same value
So once an Entity is touched, there’s no way of telling if a property contains the original value or not.
Good to know. ;)

One response so far

  1. i just stumbled across this in rc1, I can’t believe that it hasn’t gotten more attention.

Leave a Reply