using Hg.Core.Entity.HgCrm; using Hg.Core.Entity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; namespace Hg.Core.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(x => x.DeptmentGroup) .WithMany(x => x.Deptments) .HasForeignKey(x => x.Groupid); modelBuilder.Entity() .HasOne(x => x.ZhiboSystemSchedulesPlayback) .WithMany(x => x.LiveAuditLogPlayBack) .HasForeignKey(x => x.playBackId); modelBuilder.Entity() .HasOne(x => x.CMS_LiveAuditLog) .WithMany(x => x.LiveAuditLogPlayBack) .HasForeignKey(x => x.logId); modelBuilder.Entity() .HasNoKey(); modelBuilder.Entity() .HasOne(x => x.Lecturer) .WithMany(x => x.ComplianceCheckStatus) .HasForeignKey(x => x.SourceId); modelBuilder.Entity() .HasOne(x => x.News) .WithMany(x => x.ComplianceCheckStatus) .HasForeignKey(x => x.SourceId); modelBuilder.Entity() .HasOne(x => x.ZhiboSystemPlan) .WithMany(x => x.ComplianceCheckStatus) .HasForeignKey(x => x.SourceId); base.OnModelCreating(modelBuilder); } public DbSet DeptmentGroup { get; set; } public DbSet Deptment { get; set; } public DbSet Risktips { get; set; } public DbSet ZhiboSystemRoom { get; set; } public DbSet ZhiboSystemSchedules { get; set; } public DbSet Tiktok { get; set; } public DbSet WeiXinChannels { get; set; } public DbSet KuaiShou { get; set; } public DbSet Lecturer { get; set; } public DbSet ZhiboSystemSchedulesToRoom { get; set; } public DbSet LivePlatform { get; set; } public DbSet LiveAuditLog { get; set; } public DbSet LiveAuditLogPlayBack { get; set; } public DbSet ZhiboSystemSchedulesPlayback { get; set; } public DbSet ZhiboSystemPlan { get; set; } public DbSet ZhiboSystemPlanLog { get; set; } public DbSet ZhibosySytemPlanCheckStatusLog { get; set; } public DbSet ZhiboSystemPlanStatusLog { get; set; } public DbSet ComplianceCheckStatus { get; set; } public DbSet News { get; set; } public DbSet NewsClass { get; set; } public DbSet NewsContent { get; set; } public DbSet Authors { get; set; } public DbSet NewsSubType { get; set; } } }