Freigeben über


Remember to re-enable MARS in your SQL Azure based EF apps


The information in this post is out of date.

Visit msdn.com/data/ef for the latest information on current and past releases of EF.

For using EF with SQL Azure see https://msdn.com/data/jj556244


MARS (Multiple Active Result Sets) is a feature in SQL Server / ADO.NET that allows for multiple results-sets to be streamed over a single connection; this enables for simpler programmability in many scenarios. Entity Framework leverages MARS for supporting features such as lazy loading (for example, consider the case where you are iterating over a set of customers, and loading the set of orders for each customer that is returned).

MARS is turned ON by default when you use the Entity Framework designer to build your application for SQL Server – however, Entity Designer in Visual Studio 2010 turns it OFF if your database is on SQL Azure. This was done because SQL Azure did not support MARS until recently.

Now that MARS is available on SQL Azure, it is a good idea to make sure that MARS is turned on after you generate your model based on SQL Azure. Simply find the connection string that is generated and set MultipleActiveResultSets to true.

Needless to say, we will make sure that MARS is automatically turned ON for SQL Azure based apps when we get around to releasing the next update to the product.

Hope you find this helpful.

Faisal Mohamood – Program Manager, Entity Framework