SQL Server Profiler showing EF queries against master database?

What am I missing here? The queries I see in SQL Server Profiler are all targeted against the master database, which makes it difficult to filter by database name ... which event or events should I be watching so I can filter by database name.

The bigger question, what exactly is going on here?


You should remove this 'MultipleActiveResultSets=True' from your EntityFramework connection


after that, you can see the target database name show in the Profiler , instead of master.

In my option, maybe ADO.NET team want to make use the MultipleActiveResultSets feature to get

data from DB, so they have to access master.

MultipleActiveResultSets is about raise one query and don't return all its result (like in foreach statement in LINQ) , and in the same time ,raise another query to get another data in the same session.

By default, this behavior is not allowed by DB. SO.....

I was able to get around this issue, including leaving MARS active by adding an application name to my connection string:

Data Source=database_server;Initial Catalog=MyDatabase;Trusted Connection=true;MultipleActiveResultSets=True;Application Name=MyDatabase;

Then you can filter on application name.

If this is for SQL Server 2008 R2, in your trace properties, on the 'Events Selection' tab, check 'Show all columns'. You should then be able to create a column filter based on DatabaseName.

I believe you'll have to pause or stop your trace to make these changes.

As K Ivanov pointed out, having MARS (MultipleActiveResultSets) enabled will show the DatabaseName as master in SQL Profiler. By setting this to false, it'll show the proper DatabaseName, but then you lose the ability to have MultipleActiveResults.

you can use LoginName or HostName to filter in the profiler

For some reason, if I select the SP:CacheHit event, it now shows the queries against the correct database and I am able to filter by it. What is that event exactly?

Need Your Help

Embedded WebBrowser Control not respecting @media max-width attribute

css internet-explorer

When I embed the WebBrowser control in a window using either Active-X or the .NET WebBrowser control (thin wrapper around the Active-X) control, it doesn't seem to respect @media css attributes suc...

Translate Rails route to Asp.net MVC route

c# ruby-on-rails asp.net-mvc

I am converting routes from a Rails Application to work with a replacement Asp.net MVC application. We need to maintain all the old urls. Most of the routes convert over without issues - but I am h...