Microsoft Reports Significant Performance Improvements in Entity Framework 5
Microsoft has announced that the upcoming Entity Framework (EF) 5 could potentially improve performance up to 67 percent over EF 4.
According to the ADO.NET team blog, the application performance improvements they've seen in this version of EF are partly due to auto-compilation of LINQ to Entities queries. The feature has always been a part of the framework, but developers had to call CompiledQuery.Compile to take advantage of it. This will now be handled automatically in EF 5: the first time a query is run, it's compiled and cached, so that successive requests can avoid the compilation step completely.
EF 4 made use of a compiled query cache for ESQL queries, and EF 5 is extending this functionality to LINQ to Entity queries. Once the cache reaches 800 compiled queries an eviction algorithm kicks in that will clean the cache periodically, once every minute. Entries are removed from the cache on a LFRU (Least frequently – recently used) basis.
Performance also improves using compiled LINQ to SQL queries. The ADO.NET team notes some changes to the way that query parameters are evaluated, which has resulted in up to 600 percent performance improvements in their internal testing.
Despite efforts to deliver .NET Framework and EF releases independent of one another, the frameworks still share some core libraries: System.Data.Entity.dll, System.Data.Entity.Design.dll, and System.Web.Entity.dll. The upside to this fact is that developers using EF 4.0 should also experience performance improvements just by upgrading to .NET Framework 4.5.
Because some of the new features in EF 5, such as Enum support and Spatial datatypes, are dependent on functionality in .NET Framework 4.5, it is not expected until after .NET 4.5 is released. Microsoft announced the availability of EF 4.3 earlier this month.
Mike Hartington Jul 26, 2015