0

We have a requirement to read a load of xml files, run validation on them, transform them into entities and stores them in the database. This was being done using a repository wrapping Entity Framework.

What we have found is that Entity Framework slows the process down to the point where it doesn't process the records quickly enough. We profiled the application and the worst performing method was the SaveChanges on the EF context.

We are thinking of introducing threading as a possible solution.

Has anyone any other ideas of how we can speed up the process?

Burt
  • 7,500
  • 18
  • 67
  • 121
  • 1
    this might can help you, http://stackoverflow.com/questions/21272763/entity-framework-performance-issue-savechanges-is-very-slow, or this 1, http://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework – Se0ng11 Aug 27 '14 at 09:30
  • have you read http://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework – tschmit007 Aug 27 '14 at 09:31
  • We can't have ideas if we don't see what you're doing. – Gert Arnold Aug 27 '14 at 09:36
  • Gert, thanks for the help, we have a loop looping through a lot of xml files, reading them into objects, doing validation on the objects and saving changes. – Burt Aug 27 '14 at 09:44

1 Answers1

0

I had this problem for csv files one time. The problem was that I tried to save all my records with only one SaveChanges() because transaction was required.

I divided it (1 for 1000 records) and it resolves my performance problem. Also, you can try to disable auto detect changes during your threatment.

I hope it helps :)

devGirl
  • 58
  • 4