Kevin Bowersox
Kevin Bowersox

Reputation: 94429

Logging SQL in Entity Framework Core

I am attempting to log SQL statements in Entity Framework Core version 6.0.1, however when I attempt the following, I do not get access to the Log property in Visual Studio 2022 autocomplete, and I get a compilation error in my code if I write it manually:

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

I am using version 6.0.x as the documentation indicates is required to use this feature:

enter image description here

What has me really confused is that if I look at the DatabaseFacade class documentation, which Visual Studio indicates is the type of the Database property, I cannot find the Log property.

Can anyone explain what I'm doing wrong?

Upvotes: 1

Views: 5362

Answers (0)

Related Questions