Entity Framework Core / 7 SQL Logging

asp.net-core entity-framework-core

Question

Looking at this similar question I need to do the same thing, that is I want the SQL to be copied to my Output, but I need it done for EF Core / 7

I tried adding the LogFactory as is shown in this example

But that did not produce the SQL output either... what am I missing?

1
0
10/2/2017 4:32:52 PM

Accepted Answer

The EF Core 1.1 example you linked to should work, assuming you have the following in your Configure method in your Startup.cs:

public void Configure(
    IApplicationBuilder application, 
    IHostingEnvironment environment, 
    ILoggerFactory loggerFactory) {

        loggerFactory
            .AddConsole(LogLevel.Debug)  // This will output to the console/terminal
            .AddDebug(LogLevel.Debug);   // This will output to Visual Studio Output window

        // Your additional configuration here...
}
1
5/23/2017 12:02:39 PM

Popular Answer

You can also install dotnet tools. The repository contains command-line tools for the .NET Core CLI.

Running dotnet watch run, debugs the application as well as showing you any sql queries that are executed.

I am coding with VS code and not 100% sure if it will work in Visual Studio.



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