How to: Add, Modify, and Delete Objects
This topic shows how to modify objects in an object context and save the data to the database.
The example in this topic is based on the Adventure Works Sales Model. To run the code in this topic, you must have already added the Adventure Works Sales Model to your project and configured your project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard (Entity Framework) or How to: Manually Configure an Entity Framework Project and How to: Manually Define an Entity Data Model (Entity Framework).
Example
In this example, an object query returns a single SalesOrderHeader object based on a specified SalesOrderID. The status for this order is changed from 5 (shipped) to 1 (in process), a new item is added to the order, and the first existing item is deleted. The SaveChanges method is called to write changes to the database. The resulting state of the order is then written to the console.