For example, you may want to perform some validation, calculate some of the columns or even change data in other tables when saving changes to an entity object.
To configure such custom logic in your Data Context type, you can implement the corresponding partial methods.
By default, the Submit Changes method persists modified data via the standard insert, update and delete SQL commands (adapted to the current SQL dialect).
These commands include the 'where' clauses that are built based on the columns mapped to your entity classes and Update Checks set for these columns.
To Save Changes you will need to open an new Data Context, which will have no idea that this entity has been changed. You can do this by using the Attach method to attach this entities to the Data Context (so it is now managing it).
After you've attached it it will be in the "Unchanged" state so will not do anything on Save Changes. (This is not my actual code - it is more explicit to aid understanding): Coming back to my blog years later (Feb 2013) to reuse the above code I found it didn't work in Entity Framework Code First Model.
The update commands include setting of all changed fields, and the insert commands set all mapped columns not being auto-generated.
In some cases, this may be not the behaviour you want.
Next, we will add a model to this layer and create the business logic layer and the service interface layer.In the previous section, we created the LINQNorthwind solution.Next, we will apply LINQ to Entities to this new solution.Another file called is also generated, which contains the Product entity class. During Implementing a WCF Service in the Real World, we create a business domain object (BDO) project to hold the intermediate data between the data access objects and the service interface objects.You need to save the data model in order to see these two files in the Solution Explorer. In this section, we will also add such a project to the solution for the same purpose.