In a previous article, we saw how to Create an Entity Framework Model and Use it in Multiple Projects.In this article, we will see how to Add, Update and Delete objects in our conceptual model and push the changes to the underlying database.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.
I created a sample project using the Northwind sample database.In Jeffrey’s article, he gave an example of ‘deleting all rows where creation date was older than a month’.This is a perfect example of when a O/R Mapping framework issues multiple delete statements when a single ‘simple’ SQL statement could be written.Here are some of the problems that you have to solve: 1) How can you create these web services without having to create a separate set of entity objects (that is, we want to use the entity objects that the LINQ to SQL designer generates for us)?2) What do we have to do to get LINQ to SQL to work with entities passed in through web services?