SQL Server Home
Profiler Reports EF4 Queries as Occurring in Master
7/1/2010 1:10:02 PM
User(s) can reproduce this bug
Running SQL Server 2008 Profiler to watch the activity of a ASP.NET WebForms application that uses Entity Framework 4...The profiler output lines for the queries indicate that they are occurring in Database ID = 1 / Database Name = Master, but the queries are actually occuring in the application database, not Master.
It does not matter whether the queries are straight LINQ-to-Entities or are EF Functions that call a stored procedure. Also the login's default database is NOT master, so that is not the problem.
This bug is evident in SQL 2008 SP1 and SQL 2008 R2 RTM. However, when the database is running on a SQL 2000 SP3a instance, Profiler reports the correct database.
SQL Server 2008 R2 - Enterprise Edition
Tools (SSMS, Agent, Profiler, Migration, etc.)
Windows 7 Professional
Operating System Language
Steps to Reproduce
A zip file with example application and database are attached. Using the attached files:
1) Unzip the files and restore the database to a SQL Server 2008 or 2008 R2 instance.
2) Open Visual Studio 2010 and open the included solution file.
3) Start SQL Profiler, use the TSQL_SPs template, do not set any filtering.
4) Run the web application. The Default.aspx page contains a LINQ query to the Models table.
5) View Profiler results.
OR, to create from scratch...
1) Create an ASP.NET Web Application
2) Add an ASP.NET Entity Data Model
3) Generate the Model from the database.
4) Create a WebForms page that queries the Entity Data Model for some data (e.g. Models in the attached database example).
5) Run SQL Profiler, select the TSQL_SPs template, do not set any filtering.
6) Run the web application and navigate to the page with the query.
7) Review Profiler results.
In the Profiler results, the line item that represents the database query that was executed from the web application indicates that the query was executed in the Master database.
The Profiler results should indicate that the query was executed in the application database.
to post a comment.
Please enter a comment.
on 3/30/2011 at 8:25 PM
Please update where we can get this fix.
The workaround is no good for us. We need that setting set to True for our app to work.
Microsoft please give us a way to sort out this problem
on 3/29/2011 at 10:45 AM
Has this issue been released in a CU? If so, which CU. We are encountering this issue in our traces and would like it resolved.
on 1/27/2011 at 8:38 AM
Can you post the VSTS bug number so we can identify the fix in the next CU?
BTW, I see that file dates for CU 5 which was posted 12/23/2010 are actually 12/11/2010, so I assume we are waiting for CU 6 at this point.
on 1/26/2011 at 5:07 PM
When is the "next public cumulative update"? And where will we find it? The old SQL Server home page (microsoft.com/sql) had a link/page for downloads where one could find feature packs, hotfixes, service packs, and other useful downloads, but I can't find it anymore.
on 12/13/2010 at 4:43 PM
We have now fixed this issue for next public cumulative update for SQL Server 2008 R2. Thanks again for reporting the issue.
Umachandar, SQL Programmability Team
on 9/19/2010 at 11:24 PM
I would like to let you know that the issue you reported has been received by Microsoft SQL Server product team, and we will investigate this issue. If it is reproed, we will consider fixing it in the next release of SQL Server.
Microsoft SQL Server Program Manager
on 7/5/2010 at 11:25 PM
I created a second version of this project and Entity Data Model, this time utilizing stored procedures for selection and updating of data. Similar results were found (see attached file EFProfileUpdateWithSPROC.trc) where the SELECTION stored procedure AND all of the UPDATE stored procedure calls are listed as though they occurred in Master; however I can assure you that these stored procedures do not exist in Master, but rather actually exist in the application database.
on 7/5/2010 at 10:54 PM
The attached profiler trace file represents another page that was created which loops through a series of Model records and updates the names with a suffix of "-x1". Notice that the SELECT of the records (line 4 SQL:BatchStarting) is listed as occurring in Master. Also notice that the beginning of the updates, the first RPC:Starting (line 8) shows as having occurred in Master, but all the subsequent updates (both RPC:Starting and SP:StmtStarting events) appear in the proper application database (ID=9, name=PhoneStore).
to post a workaround.
Please enter a workaround.
on 8/9/2010 at 11:32 PM
Setting the MultipleActiveResultSets option in the connection string in web.config to FALSE causes Profiler to properly report the query as having been executed in the application database.
© 2014 Microsoft