Object-Relational Mapping frameworks are a convenient way to provide an abstraction for data access in an object-oriented application. NET applications, Microsoft's recommended O/RM is the Entity Framework.With any abstraction though, performance can become a concern.This whitepaper was written to show the performance considerations when developing applications using the Entity Framework, to give developers an idea of the Entity Framework internal algorithms that can affect performance, and to provide tips for investigation and improving performance in their applications that use the Entity Framework.
We have included some test metrics to demonstrate performance, but these metrics aren't intended as absolute indicators of the performance you will see in your application. NET 4.5, and can offer a big performance benefit to those who haven’t upgraded from .
For practical purposes, this document assumes Entity Framework 4 is run under . NET 4.0 but want the latest Entity Framework bits in their application.
NET 4.0 and Entity Framework 5 and 6 are run under . Many of the performance improvements made for Entity Framework 5 reside within the core components that ship with . Entity Framework 6 is an out of band release and does not depend on the Entity Framework components that ship with . When this document mentions Entity Framework 6, it refers to the latest version available at the time of this writing: version 6.1.0.
The very first time any query is made against a given model, the Entity Framework does a lot of work behind the scenes to load and validate the model.
We frequently refer to this first query as a "cold" query.
Further queries against an already loaded model are known as "warm" queries, and are much faster.
Let’s take a high-level view of where time is spent when executing a query using Entity Framework, and see where things are improving in Entity Framework 6.
First Query Execution – cold query There are several ways to reduce the performance cost of both cold and warm queries, and we'll take a look at these in the following section.
Specifically, we'll look at reducing the cost of model loading in cold queries by using pre-generated views, which should help alleviate performance pains experienced during view generation.