entity-frameworkentity-framework-4wcf-ria-servicessubmitchangesobjectstatemanager

ObjectStateManager and Detached entity state


I'm using Entity Framework and some parts of its functionality are still unclear for me. The main things that are hard to understand are:

Provide your explanations or give some useful links.


Solution

  • ObjectStateManager is a component exposing information about tracked entities. Each entity which can be persisted by EF must be tracked = attached. Detached entities are unknown to EF (they are not tracked) and so their changes are not saved when you call SaveChanges (there is no SubmitChanges in EF). Tracking consists of maintaining information about initial state of the entity or relation and changes done to them. It also contains the global state of the entity.

    The process when you call SaveChanges depends on the way how you configured EF to track changes, on the way how you got the entity and on the changes you did.

    Change tracking is a feature which allows EF to track changes applied on entities attached to the context (each entity loaded by the query is by default attached). EF contains to version of change tracking:

    The order of data modification operations is EF internal implementation. The basic order is defined by your mapping where dependency between entities is described.