Using Entity Framework 4 in an ASP.NET web application with stored procedures and calling SQL Server 2008 SP1...
When running SQL Server Profiler (TSQL_SPs template), the lines that show my stored procedure call and its statements say that they executed in DatabaseID = 1 (Master) but the procedures actually exist in my application database (ID = 8). The procedures
execute properly and return the data, and they only exist in my application database, so why does Profiler mark those lines as being in Master? Is this a bug in Profiler? Is it a bug in EF4?
Note that running the same code against a SQL 2000 instance, Profiler correctly shows the application's database ID.
Learned a work-around from
Olaf Tinnemeyer on StackOverflow: Changing the MultipleActiveResultSets option in the Connection String to
FALSE causes Profiler to properly report the query as being executed in the application database.
I still think this is a bug in SQL 2008, but I can live with the work-around for now.
Marked as answer by AjarnMark on Aug 10, 2010 06:29 AM
AjarnMark
Member
141 Points
36 Posts
SQL Profiler confused by Entity Framework 4
Jun 08, 2010 04:24 PM|LINK
Using Entity Framework 4 in an ASP.NET web application with stored procedures and calling SQL Server 2008 SP1...
When running SQL Server Profiler (TSQL_SPs template), the lines that show my stored procedure call and its statements say that they executed in DatabaseID = 1 (Master) but the procedures actually exist in my application database (ID = 8). The procedures execute properly and return the data, and they only exist in my application database, so why does Profiler mark those lines as being in Master? Is this a bug in Profiler? Is it a bug in EF4?
Note that running the same code against a SQL 2000 instance, Profiler correctly shows the application's database ID.
sql server 2008 SQL 2008 EF4 entity-framework
AjarnMark
Member
141 Points
36 Posts
Re: SQL Profiler confused by Entity Framework 4
Jun 23, 2010 09:26 PM|LINK
UPDATE: I have now tested this on a new installation of SQL Server 2008 R2 and it still displays this as if it happened in Master.
AjarnMark
Member
141 Points
36 Posts
Re: SQL Profiler confused by Entity Framework 4
Jul 01, 2010 08:21 PM|LINK
UPDATE 2: This has been logged to Connect at https://connect.microsoft.com/SQLServer/feedback/details/572246/profiler-reports-ef4-queries-as-occurring-in-master.
AjarnMark
Member
141 Points
36 Posts
Re: SQL Profiler confused by Entity Framework 4
Aug 10, 2010 06:29 AM|LINK
Learned a work-around from Olaf Tinnemeyer on StackOverflow: Changing the MultipleActiveResultSets option in the Connection String to FALSE causes Profiler to properly report the query as being executed in the application database.
I still think this is a bug in SQL 2008, but I can live with the work-around for now.