mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Use Serilog in EntityFramework Core logging.
This commit is contained in:
@@ -41,13 +41,13 @@ public sealed class Context(DbContextOptions options) : DbContext(options)
|
||||
public DbSet<MediaByMachine> MediasByMachines { get; set; }
|
||||
public DbSet<RomSetStat> RomSetStats { get; set; }
|
||||
|
||||
public static Context Create(string dbPath)
|
||||
public static Context Create(string dbPath, ILoggerFactory loggerFactory)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder();
|
||||
|
||||
optionsBuilder.UseLazyLoadingProxies()
|
||||
#if DEBUG
|
||||
.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()))
|
||||
.UseLoggerFactory(loggerFactory)
|
||||
#endif
|
||||
.UseSqlite($"Data Source={dbPath}");
|
||||
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
*******************************************************************************/
|
||||
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.Database;
|
||||
|
||||
public class ContextFactory : IDesignTimeDbContextFactory<Context>
|
||||
{
|
||||
public Context CreateDbContext(string[] args) => Context.Create("romrepo.db");
|
||||
public Context CreateDbContext(string[] args) =>
|
||||
Context.Create("romrepo.db", LoggerFactory.Create(builder => builder.AddConsole()));
|
||||
}
|
||||
Reference in New Issue
Block a user