How can I log my SQL queries in Visual Studio 2013?

I used to work great. I would just select the output window and all calls will be logged and displayed. But then I reinstalled VS 2013, and now I can’t see anything.

Please note that this is a built-in function. Not what I was doing with debugging calls or anything in my code.

I’ve been doing this for over a year now and just can’t understand which option I chose to make this happen. Can anyone remember how to do this?

+8
sql-server visual-studio-2013 asp.net-web-api
source share
3 answers

Starting with EF 6.0 you would do

using (var context = new BlogContext()) { context.Database.Log = Console.Write; // Other code here... } 

From here: Registration and interception of database operations

+6
source share

For VS2013 Pro, I can’t get the request in the output window, but you can make it a log in the message bar of the query results. Is that what you are talking about?

 Tools > Options > SQL Server Tools > Transact-SQL-Editor > Query Results > Results to Grid 

Check "Include query in result set" enter image description hereenter image description here

+1
source share

Are you talking about IntelliTrace? However, it is only available in VS Ultimate versions. See Intellitrace not available for VS 2012 Professional edition?

0
source share

All Articles