Entity Framework slow after upgrade from EF4 to EF6 (EntityFramework.6.2.0)

c# entity-framework-4 entity-framework-6


I'm upgrading an old MVC web application from EF4 to EF6 (and MVC3 to MVC5) using a guide i found on SO.

Functionally appears OK, but I've noticed performance issues.

Specific requests on the prod env for this application running MVC3/EF4 finish in under half a second. Same in my Dev system after update take seconds.

For comparison, I've created an new test MVC/EF6 solution on the same dev machine that I am working on the migrated application. I surfaced the below linq via an MCV action, and have found there is a big performance difference, between the two to applications.

Note: both the old and test application have no overheads in the controller constructor, they both only creating the dbContext, and run the query.

var sites = DB.Sites.Take(50).Include("Users").OrderBy(s => s.SiteName).ToList();

new test EF6 application: 200ms old application upgraded: 2 seconds

I have profiled the requests on SQL Server, and I can't see any problem there.

I am considering removing the ADO Entity Framework from the old project and starting by adding again. but this was a model first application, and doing this appears to remove all the partial classes, where the metadata has been defined (resulting in lots of compilation errors).

  • Should I remove the ADO Entity Framework from the old project - and recreate as a database first application?
  • Is there something I have missed - that could be causing the issue?
  • how can i find out where the time is being used?


I removed the ADO Entity Framework model(edmx) and rediscovered from the database. This resulted in a lot of refactoring, due to pluralisation difference between EF4 and EF6. There were also changes to the Add/Update/Delete entities behaviours.

This hasn't resolve the performance issue.

10/1/2019 2:22:08 PM

Popular Answer


in the upgraded app's web.config I found the connection string had: Pooling=False; I removed this.

Additionally in my test app, I found the connectiton string had: App=EntityFramework

The performance immediately improved to that of the test application

10/2/2019 1:15:22 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow