Performing Other Data Operations
Now that we have consolidated the code that accesses the data model, we can add pages to our web application to handle other data operations. In the following sections, you will learn how to create, modify, and delete data from the database using the Entity Framework.
Adding new data using the entity data model is a four-step process:
- Create a new instance of the entity class that represents rows of the table of interest.
- Set values for the parameters of the entity object we created.
- Add the object to the collection of similar objects maintained by the entity context.
- Call the
SaveChangesmethod to write the change to the database.
Because we have consolidated our data-access code, these four steps ...