Log Queries executed by Entity Framework DbContext

asp.net-mvc-5 c# entity-framework entity-framework-6 linq

Accepted Answer

You can find the article you're looking for at MSDN.

The DbContext.Database.Log Any method that accepts a string has a property that can be assigned to a delegate. It is typically used with anyTextWriter by setting it to the TextWriter's "oeWrite" function. The current context will log every SQL statement to that writer. As an illustration, the code below will log SQL to the console:

using (var context = new BlogContext())
{
    context.Database.Log = Console.Write;

    // Your code here...
}
59
5/22/2014 10:56:23 AM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow