Microsoft plans pre-compiled queries for Entity Framework, and may replace old and crufty .NET SQL Server provider

Microsoft has published its plans for Entity Framework (EF) Core 8, its .NET ORM (Object-relational mapping) library, including a proposal for pre-compiling queries, better support for “database first” models, full support for JSON columns, and a new experimental SQL Server provider for .NET, codenamed “Woodstar.”

Entity Framework is widely used and according to Principal Software Engineering Manager Arthur Vickers, speaking at an online community standup last week, the current version, EF7, has been downloaded over 1 million times from NuGet, the .NET package repository. The forthcoming EF8 will target .NET 8.0, expected in November 2023, which will be a long-term support release.

One of the issues with Entity Framework is that it does a lot of dynamic code generation at runtime, which means it cannot take advantage of native AOT (ahead of time) compilation introduced in .NET 7.0. AOT can improve both start-up time and application size.

Microsoft is investigating how to change this, so that more query code is generated at design-time and can therefore be AOT compiled. “It’s an attempt to make EF Core fit into this model,” said Principal Software Engineer Shay Rojansky, “making your EF Core applications start faster and potentially be far smaller, making them more relevant for places like mobile devices or Blazor Wasm applications or serverless computing in the cloud.”

None of this is certain. “We are not committed to delivering this,” said Rojansky. “Actually making EF compatible with native AOT is larger than this, and it might be blocked on something else … it’s a big endeavor.”

Another idea is to redesign the SQL Server .NET provider. “Woodstar is the idea that we will create a modern driver for SQL Server and/or Azure SQL,” said Vickers. “Azure SQL is the main focus.”

In this context, modern means using newer .NET technology and programming patterns for performance. “It is not going to replace Microsoft.Data.SqlClient,” said Vickers, because of the huge legacy of applications which use it. Woodstar will have more limited compatibility with SQL Server versions.

Rojansky added that “SqlClient is a very old driver … it’s accumulated lots of legacy debt. In addition to performance there are some fundamental issues in SqlClient that are hard to fix without a substantial redesign. I’m talking about bugs and severe performance issues, on the edges.”

“We are not delivering a supported driver for 8.0, that people should be using,” said Rojansky.  “This is an experiment at this point.”

Another feature planned for EF 8 is improved support for JSON columns. This was introduced in EF7, but only for SQL Server and with some limitations. EF8 will bring this to other database providers, including SQLite.

The plans for EF8 can be tracked in the official roadmap.