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 Data

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 SaveChanges method to write the change to the database.

Because we have consolidated our data-access code, these four steps ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.