Home > Enterprise >  Entity Framework Core 6 logs all queries as warnings
Entity Framework Core 6 logs all queries as warnings

Time:12-19

Whenever I'm calling my context through EF Core 6, I'm getting the resulting query outputted as a warning in my logs.

I'm calling the context through LINQ like this:

var result = await _context.Table.FirstOrDefaultAsync();

The warning I'm getting in the logs looks like this (with the individual columns instead of the *):

warn: Microsoft.EntityFrameworkCore.Database.Command[20100]
      Executing DbCommand [Parameters=[@__deviceId_0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) *
FROM [Table] AS [o]

I've made sure that all of the columns that can contain a null value are noted as such in the dataobject.

What can I have overlooked? I can't figure out what could result in these warnings.

CodePudding user response:

It turned out a colleague had configured logging for CommandExecuting as warnings in the context itself

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.ConfigureWarnings(c => c.Log((RelationalEventId.CommandExecuting, LogLevel.Warning)));
    }
  • Related