32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using DG.EntityFramework;
|
|
using Hg.Core.Entity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
using Microsoft.EntityFrameworkCore.Internal;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Hg.Core.EntityFramework
|
|
{
|
|
public class CrmDbContext : DbContext
|
|
{
|
|
public CrmDbContext(DbContextOptions<CrmDbContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
|
{
|
|
var loggerFactory = new LoggerFactory();
|
|
loggerFactory.AddProvider(new EFLoggerProvider());
|
|
optionsBuilder.UseLoggerFactory(loggerFactory);
|
|
}
|
|
optionsBuilder.ConfigureWarnings(b => b.Ignore(CoreEventId.ContextInitialized));
|
|
base.OnConfiguring(optionsBuilder);
|
|
}
|
|
|
|
public DbSet<TraceUser> TraceUser { get; set; }
|
|
|
|
}
|
|
} |