[翻译]  How can I log my SQL calls in Visual Studio 2013?

[CHINESE]  如何在Visual Studio 2013中记录SQL调用?


I used to have it working great. I would just select the output window and all the calls would be logged and output. But then I reinstalled VS 2013 and now I see nothing.

我曾经让它运作得很好。我只需选择输出窗口,所有的调用都将被记录并输出。但后来我重新安装了VS 2013,现在我什么也没看到。

Please note this is a built in feature. Not something I used to do with debug calls or anything in my code.

请注意,这是一个内置功能。这不是我以前用调试调用或代码中的任何东西做的事情。

I have been doing this for over a year now and just cannot figure out what option I selected to make it happen. Can anyone remember how to do this?

我已经这样做了一年多了,只是无法弄清楚我选择了什么选项来实现它。谁能记得怎么做?

3 个解决方案

#1


6  

Starting with EF 6.0 you would do

从EF 6.0开始你会这样做

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

From here: Logging and Intercepting Database Operations

从这里:记录和拦截数据库操作

#2


1  

For VS2013 Pro, I can't get the query to the output window, but you can make it log to the Message pane of the query results. Is this what you're referring to?

对于VS2013 Pro,我无法将查询提供给输出窗口,但您可以将其登录到查询结果的“消息”窗格。这是你指的是什么?

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

Check 'Include the query in the result set'enter image description here enter image description here

选中“在结果集中包含查询”

#3


0  

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

你在谈论IntelliTrace吗?但它仅适用于VS Ultimate版本。请参阅Intellitrace不适用于VS 2012专业版?


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号