using DG.EntityFramework; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Logging; namespace Zxd.EntityFramework { public class DncmsbaseDbContext : DbContext { public DncmsbaseDbContext(DbContextOptions 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) { modelBuilder.Entity() .HasOne(b => b.Deptment) .WithMany(x => x.DeptmentCampainIds) .HasForeignKey(b => b.DeptId); modelBuilder.Entity().HasKey(c => new { c.Appid, c.Userid, c.Externaluserid }); modelBuilder.Entity().HasKey(c => new { c.eid, c.salegroupid }); base.OnModelCreating(modelBuilder); } public DbSet Deptment { get; set; } public DbSet ResResidWeworkEventLog { get; set; } public DbSet ResResidWeworkUser { get; set; } public DbSet ResResidWeworkUserLog { get; set; } public DbSet DeptmentCampainId { get; set; } public DbSet WeworkExternalUser { get; set; } public DbSet ResCutomerPassTime { get; set; } public DbSet ResourceProtectInfo { get; set; } public DbSet Wx_Szzyorder_log { get; set; } public DbSet resourcetag { get; set; } public DbSet weworkuser2eid { get; set; } public DbSet EmployeeDepartmentDetail { get; set; } public DbSet EmployeeDepartmentFull { get; set; } public DbSet Department { get; set; } public DbSet AssignRules { get; set; } public DbSet Assign { get; set; } public DbSet WeworkAgent { get; set; } } }