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

asked 01 Sep, 11:29

TaniAvigail's gravatar image

TaniAvigail
112
accept rate: 0%

edited 06 Sep, 09:53

Volker%20Barth's gravatar image

Volker Barth
38.8k351528799

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.

(06 Sep, 08:55) Chris Keating
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×268
×68

question asked: 01 Sep, 11:29

question was seen: 110 times

last updated: 06 Sep, 09:53