Hi, I have a programm that need to update and insert big amount of data to DB (about 1000-2000 rows) update with EF is very slow and takes a lot of time, sometimes it's even worst , it's terminats in the middle withou finish all data. Can you please advice how to handle such requirement? Tania |
I do not have any experience with EF but bulk operation performance appears to be a common problem with EF. Common suggestions are to use
yourContext.Configuration.AutoDetectChangesEnabled = false; yourContext.Configuration.ValidateOnSaveEnabled = false;
Perform SaveChanges() on sets of rows - set size vary depending on the poster so you may want to experiment.
Rebuild the context after n number of inserts. Again, n varies depending on the poster - like SaveChanges, experiment.