Entity framework performance issue, saveChanges is very slow

Turn off change tracking before you perform your inserts. This will improve your performance significantly (magnitudes of order). Putting SaveChanges() outside your loop will help as well, but turning off change tracking will help even more.

using (var context = new CustomerContext())
    context.Configuration.AutoDetectChangesEnabled = false;

    // A loop to add all your new entities


See this page for some more information.

Leave a Comment