Performance on Entity Framework

EntityFramework Performance and AutoDetectChanges

Speeding up Entity Framework queries with CompiledQuery

Performance and the Entity Framework

Performance Considerations (Entity Framework)

Why is inserting entities in EF 4.1 so slow compared to ObjectContext?

Fastest Way of Inserting in Entity Framework

Obviously, the speed on executing EF Queries is slow so these articles (and more out there in the web) describe about the EF performance and small tips how to optimize/reduce the actual operation time in EF.

The ones that I have been using are two properties in DbContextConfiguration ; AutoDetectChanges, ValidateOnSaveEnabled. Since EF keeps tracking changes on changes/updates/insert and validating data when saving, briefly saying, EF does check for data’s navigation properties and all related data. That’s why it is slow for executing queries.

But be cautious that if you set those properties to ‘false’ before DbContext.{Add/Insert/Update/SaveChanges} calls, then it would be a better idea you set them back to ‘true’ once done. Because having them ‘true’ enables the EF performs the auto data validation and checking on data-relationship for you.

Enjoy reading articles! 🙂


Links for Entity Framework Code-Frist

Entity Data Model

How to: Create a New .edmx File

Get Started with Entity Framework (EF)

Code First Conventions

EFMVC – ASP.NET MVC 4, Entity Framework 5 Code First and Windows Azure

Code First with Entity Framework 5 using MVC4 and MVC Scaffold

Pros and cons for Entity Framework Code-First



Lightweight entity classes or POCO based.

More control over entity classes since you code them yourself rather than depending on EF to generate them. This means you don’t have to define partial classes to do data annotations.

Option to never have to specify mapping anywhere. Convention takes over configuration.

DbContext follows the repository pattern.

Lazy loading, related entity loading all taken care of for you. For example a Post model can declare Author model in the POCO and EF Code first will map this relation automatically. Again use of convention makes us so productive.

Works great for greenfield applications.

ASP.NET MVC view generation works great.

ModelBinder works as per normal.


No API support for customizing the database mapping convention like in Fluent nHibernate.Bit difficult to map to existing databases.(This might change in the release version).