Why do a small amount of add/deletes take several seconds in EF4?

Posted by TomWij on Stack Overflow See other posts from Stack Overflow or by TomWij
Published on 2010-12-23T21:49:14Z Indexed on 2010/12/23 21:54 UTC
Read the original article Hit count: 199

Using the Entity Framework 4. I have created a Code First database in the past and a piece of code needs to delete and add 16 objects, this takes 6 seconds each. That's 300+ ms for each query!

The deletes/adds occur in a foreach scope and there is a SaveChanges() outside the foreach.

alt text

In the above image you see that each takes 6 seconds, which is 34% of the time, for 16 calls.

That doesn't sound normal to me... Why is this and how can I improve the performance?

If there is no solution: Are there any workarounds I can use? It would be a pain to rewrite my project...

© Stack Overflow or respective owner

Related posts about c#

Related posts about Performance