From 25ede5cc28076ce132acb16ea97e10ba39a46570 Mon Sep 17 00:00:00 2001 From: Kevin Matsubara Date: Fri, 4 Apr 2025 20:12:03 +0200 Subject: [PATCH] Add logging to Entity Framework Core workload. --- EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs b/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs index 4027b46..0b1eaf7 100644 --- a/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs +++ b/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using EntityFrameworkCore.Domain; +using Microsoft.Extensions.Logging; namespace EntityFrameworkCore.Data; @@ -19,7 +20,10 @@ public class DeadBallZoneLeagueDbContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite($"Data source={DbPath}"); + optionsBuilder.UseSqlite($"Data source={DbPath}") + .LogTo(Console.WriteLine, LogLevel.Information) + .EnableSensitiveDataLogging() // Do not allow this in Production. + .EnableDetailedErrors(); // Do not allow this in Production. } protected override void OnModelCreating(ModelBuilder modelBuilder)