I am in the process of upgrading an application from EF1 to EF4.1 I created a DbContext and a set of POCOs using the "ADO.NET DbContext Generator" templates.
When I query the generated DbContext the database part of the query takes 4ms to execute (validated with EF Profiler). And then it takes the context about 40 seconds (in words: FORTY!) to do whatever it does before it returns the result to the application.
EF1 handles the same query in less than 2 seconds.
Turning off AutoDetectChanges, LazyLoading and ProxyGeneration wins me 2-3 seconds.
When I use the AsNoTracking() extension method I am able to reduce the total execution time to about 3 seconds.
That indicates that ChangeTracking is the culprit.
But ChangeTracking is what I need. I must be able to eventually persist all changes without having to handpick which entities were modified.
Any ideas how I could solve that performance issue?