Please give a brief description of the Entity Framework lifecycle with a suitable image.
Explain lifecycle of entity framework?
68905-Feb-2020
Updated on 05-Feb-2020
Home / DeveloperSection / Forums / Explain lifecycle of entity framework?
Please give a brief description of the Entity Framework lifecycle with a suitable image.
Nishi Tiwari
05-Feb-2020The Entity Lifecycle is defined as the process in which an Entity is created, added, modified, deleted, etc. These Entities have many states during its lifetime. So, before looking at how to retrieve entity state, look at what is entity state. These states are an enum of type System.Data.EntityState that declares the following values −
• Added: An entity is marked as added.
• Deleted: An entity is marked as deleted.
• Modified: The entity has been modified.
• Unchanged: The entity hasn’t been modified.
• Detached: The entity isn’t tracked.
State Changes in the Entity Lifecycle
When sometimes the state of entities are set automatically by the context, but it can also be modified manually by the developer. If all the combinations of switches from one state to another are possible, but some of them are meaningless for example, the Added entity to the Deleted state, or vice versa.
Unchanged State
Detached State
Added State
Modified State
Deleted State