POCO / Change Tracking Question RRS feed

  • Question

  • I'm very new to EF, and am just trying to get my arms around it for now (so apologies for any basic questions I may throw out).  Anyway, I created a model and generated POCO classes using the stock T4 templates provided by Microsoft.  Everything appears to work fine.  I've noticed one little quirk with change tracking, though, and would like to better understand what is going on.

    When ProxyCreationEnabled is set to false on the ObjectContext, dynamic proxies are disabled and changes are detected via snapshot comparisons.  When ProxyCreationEnabled is set to true (and dynamic proxies are enabled), changes are tracked when a property value is changed.  I've tested both scenarios out, and in the end, comparisons are identical -- except when (for whatever reason) an entity property is assigned a value that happens to be the same as the original value.  When this happens, snapshot comparison will correctly determine that no changes have occurred.  However, when utilizing dynamic proxies, the entity state will be set to Modified -- even though the value didn't really change.  It's as if the setter has no logic to compare the old / new values of the property.

    Am I missing something?  Shouldn't the dynamic proxies perform a comparison between the old / new values before changing the entity state?  Or am I just expecting too much?  Either way is fine.  I just want to understand what is going on under the hood so I don't make any faulty assumptions when I code.



    Tuesday, January 25, 2011 7:22 AM


All replies