If you want to use the SaveOptions.None, when calling the method DbContext.SaveChanges, you must override de function in a partial class, like:

 

/// <summary> /// </summary> public partial class MyEntities : IMyEntities { /// <summary> /// Dynamically set connection string and configure Entity Framework. /// </summary> /// <param name="connection"></param> public Myntities(string connection) : base(connection) { // Set Configuration.AutoDetectChangesEnabled = false to improve performance (100x). Configuration.AutoDetectChangesEnabled = false; // By default use lazyloading. Configuration.LazyLoadingEnabled = true; // Don't valid entities on save. Configuration.ValidateOnSaveEnabled = false; }

/// <summary> /// Override the default save changes so, because we have disabled "AutoDetectChangesEnabled". /// </summary> /// <returns></returns> public override int SaveChanges() { return (this as IObjectContextAdapter).ObjectContext.SaveChanges(System.Data.Objects.SaveOptions.None); }

 

}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.