Ajarn Mark Caldwell Blog

Bringing Business Sense to the IT World…

Work-Around for Odd Profiler Results with EF4

A couple of months ago I wrote a post about Odd Profiler Results with Entity Framework 4.  Thanks to Olaf Tinnemeyer, we now have a simple work-around that he posted to my question on StackOverflow.

When using the Visual Studio tools to create the Entity Data Model, it automatically builds the Connection String for you, and one of the default settings is to set the MultipleActiveResultSets option to True.  If you change this setting to False, then Profiler will properly report that the query was executed within the application database.

Please note that I have not done any load testing to determine what type of performance impact this change might have, so YMMV.  But for me, I know it will perform acceptably for our needs, and the greater need in my view is to have accurate Profiler results.

I have posted this work-around to the Connect item that I opened.  I still believe that this is a bug in SQL Server and hope that Microsoft will address it in a future release.  If you share my concern, I encourage you to login and vote this up.

Legacy Comments


Jack Corbett
2010-08-10
re: Work-Around for Odd Profiler Results with EF4
Interesting results. I wonder if that is a bug in SQL Server or in ADO.NET when it is connecting?

AjarnMark
2010-08-13
re: Work-Around for Odd Profiler Results with EF4
Good question, Jack. I'm guessing that it is really some combination because if I change the Server parameter to a SQL 2000 instance, everything works fine, but I think that is because SQL 2000 does not support MARS, so it behaves as if MARS was turned off.