38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using DG.EntityFramework;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
using Microsoft.Extensions.Logging;
|
|
using Zxd.Entity.SSO;
|
|
|
|
namespace Zxd.EntityFramework
|
|
{
|
|
public class SSODbContext : DbContext
|
|
{
|
|
public SSODbContext(DbContextOptions<SSODbContext> 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);
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
|
|
public DbSet<Entity.SSO.Department> Department { get; set; }
|
|
public DbSet<Entity.SSO.Employee> Employee { get; set; }
|
|
public DbSet<Zxd.Entity.SSO.EmployeeDepartment> EmployeeDepartment { get; set; }
|
|
public DbSet<DepartmentCrmConf> DepartmentCrmConf { get; set; }
|
|
}
|
|
} |