I am using Entity Framework Core on the nightly build channel (right now I'm using version EntityFramework.7.0.0-beta2-11524) and I'm trying to log the queries that EF generates just out of curiosity.
I'm writing a simple console program, I tried using the same logging technique that EF6 uses, but DbContext.Database.Log
is not available on Entity Framework Core. Is there a way to log or just take a peek at the SQL generated by EF Core?
This is how I got it working based on Avi Cherry's comment:
You can actually just add an ILoggerFactory parameter to your "Configure" method in Startup.cs and call .AddConsole() to it right there.
In your Startup.cs you probably have a Configure method with a bunch of configurations in it. It should look like below (in addition to your stuff):
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
//this is the magic line
loggerFactory.AddDebug(LogLevel.Debug); // formerly LogLevel.Verbose
//your other stuff
}