Disabling Automatic Validation on Save Changes Method in Entity Framework 6.0

Introduction
 

When youcall SaveChanges method of context, by default the entity framework validatesthe data of all changed properties before updating the database. If we havelarge number of entities need to be updated and these entities are alreadyvalidated the data, this is unnecessary overhead.

 

We can temporarilyturn off the model validation by setting ValidateOnSaveEnabled of context tofalse. By default this property set to true.

 

Example

using (var Context = new TestdbEntities())
{
    Context.Configuration.ValidateOnSaveEnabled =
false;
}

Ebook Download
View all
Learn
View all