Before we make additions and deletions, it is important to understand the life cycle of an entity and how it is manipulated by EF.
During the life cycle of an entity, each entity's context-based operations have an entity state, which is the value of an enumerated type: System.Data.Entity.EntityState, which contains the following values:
1.Added
2.Deleted
3.Modified
4.Unchanged
5.Detached
The data context contains not only references to all objects retrieved from the database, but also the entity state of the entity object, which maintains the properties of the modified entity, which is called change tracking.
The change in entity state from "unchaged" to "Modified" is handled automatically by the data context, so other state changes must be made using DbContext and dbset appropriate methods.
The following diagram lists the actions that change the state of the entity, which in turn affects the operation of the database.
A new entity, when saved, is generated by the Insert command;
Querying an entity, the state of the entity is unchanged;
After modifying the entity, save again, that is update;
Remove is Delete
Entity life cycle (EF Basic Series 8)