1.nuget安装 Microsoft.Extensions.Logging.Debug
2.修改dbcontext类
public static readonly LoggerFactory LoggerFactory = new LoggerFactory(new[] { new DebugLoggerProvider() });
重写该方法
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLoggerFactory(LoggerFactory);
base.OnConfiguring(optionsBuilder);
}
3.查看sql
参考https://www.cnblogs.com/fb208/p/11551396.html