Entity Framework dramatically faster in .NET 4.5

The Entity Framework is often shown lagging behind in performance comparisons with other ORM’s, especially when micro ORM’s are also included in the mix.

For example the Dapper benchmarks show the Entity Framework in a distant last place when testing SELECT mapping and serialization. These results have been charted on the excellent ServiceStack website.

However things have changed in .net 4.5 and the Entity Framework is no longer the slouch it once was.

The chart below shows the same benchmark, but this time including how the ORM’s fare when run on .NET 4.5.

The benchmark measures how long in milliseconds it takes to execute 500 SELECT statements against a DB and map the data returned to objects.

[easychart type=”vertbar” height=”100″ title=”Performance of SELECT mapping over 500 iterations” groupnames=”.NET 4.5, .NET 4″ groupcolors=”005599,229944″ valuenames=”Hand coded, Dapper,OrmLite,PetaPoco,NHibernate,EF Compiled ,EF, Linq 2 SQL,NHib LINQ” group1values=”66,67,71,75,126,133,183,188,530″ group2values=”68,69,80,78,134,133,888,212,657″]

Now the Entity Framework competes with the other ORM’s on performance, and when compared with a fully featured ORM like nHibernate it compares very favourably (at least on this one metric).

It gets nowhere near the micro-ORM’s on performance, but feature rich ORM’s never will.

What is also interesting is that quite a few of the ORM’s also gain speed improvements in .NET 4.5