0

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?

Serj Sagan
  • 28,927
  • 17
  • 154
  • 183

2 Answers2

1

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...
}
Community
  • 1
  • 1
Matt
  • 3,617
  • 2
  • 27
  • 39
  • Just for other who came here with the same problem read out [this article](https://learn.microsoft.com/en-us/ef/core/miscellaneous/logging). As this answer is not very helpful, except @Matt has added only the scaffolded code. – JB's May 04 '17 at 11:21
  • But it answered his question :( – Matt Feb 02 '18 at 20:13
0

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.

HashSix
  • 105
  • 2
  • 9