Closed schmitch closed 5 years ago
Hello @schmitch ,
I don't think that's something we would like to implement by default. We try to keep being as close as EF6 which already have somewhat his own database log: https://www.entityframeworktutorial.net/entityframework6/database-command-logging.aspx
sadly that is not possible in efcore. the only way would be to add a logger to the database driver in my case npgsql: https://www.npgsql.org/doc/logging.html
Logging in efcore is done via the LoggingFactory which EF-Classic does not implement: https://www.entityframeworktutorial.net/efcore/logging-in-entityframework-core.aspx
logging on the npgsql level would mean that both efcore and pgsql logs would be duplicated.
sadly that is not possible in efcore.
EF Classic
is not an extension of EF Core and is it expected to don't have the same behavior. It's a new whole Entity Framework version.
Are we speaking of the same library? In your text, you speak of EF Classic
but also of EF Plus
for EF Core.
well EF Classic for dotnet core (efcore) is not loggable like it was done in entityframework5/6 you can't attach a Console.WriteLine to DbContext.Database.Log. Thus it's impossible to log statements in EF Classic, the only way to log is to actually log at the driver level.
Hello @schmitch ,
I'm sorry, I still don't understand this request.
It seems we have no problem on our side to use Console.WriteLine
with the log
event.
What are we missing?
public class EntityContext : DbContext
{
public EntityContext() : base(My.ConnectionString)
{
this.Database.Log += Console.WriteLine;
}
// ...code...
}
Currently it would be great if EF-Classic would support logging via
Microsoft.Extensions.Logging.
. It took me a while to figure out that the query was really executed, since I had no visible logging, only my ef core logs would've been posted, so it first seemed that EF-Classic did not work.actually for
Z.EntityFramework.Plus.EFCore
it should be relativ simple by usingGetService<ILogger<Microsoft.EntityFrameworkCore.Database.Command>>
however would probably be problematic for ef5/ef6