section if you are using Entity Framework 5.0 with VS2012.Connected scenario: Now let’s update an existing student entity in connected scenario. Or, if you use Code-First or Model-First approach, then create entities and context classes.In any case, entities and context classes will look similar.Disconnected scenario: Now let’s update an existing student in the disconnected scenario.So in this scenario, we will fetch the student from the database and persist a modification to the database using a different context.
Thus you can update an entity in disconnected scenario.
Objects attached to the object context are managed by that object context. Observe the code shown below: All we are doing here is create a new instance of the Customer type and populate its properties.
Now there are three ways to add a new object to the object context: 1. We then add this instance to the Customers set using the Entity Set. The Add Object() method is used for adding newly created objects that do not exist in the database.
The steps to update an existing entity are quite simple.
First retrieve an instance of the entity from the Entity Set), then edit the properties of the Entity and finally call Save Changes() on the context.So in this scenario, we will fetch the student from the database and persist a modification to the database using same context.