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 ZxdDbContext : DbContext { public ZxdDbContext(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.Meeting) .WithMany(x => x.MeetingParticipants) .HasForeignKey(x => x.MeetingId); modelBuilder.Entity() .HasOne(b => b.Meeting) .WithMany(x => x.MeetingAccessories) .HasForeignKey(x => x.MeetingId); modelBuilder.Entity().HasKey(t => new { t.resid, t.username }); modelBuilder.Entity().HasKey(t => new { t.resid, t.userid, t.deptcode }); modelBuilder.Entity().HasKey(t => new { t.Id, t.Companycode }); modelBuilder.Entity().HasKey(t => new { t.INNERUSERID, t.ROLEID }); modelBuilder.Entity() .HasOne(x => x.HG_CheckQualityLog) .WithMany(x => x.HG_CheckQualityLogRelation) .HasForeignKey(x => x.logid); modelBuilder.Entity() .HasOne(x => x.HG_CheckQualityLog) .WithMany(x => x.HG_CheckQualityLogDetail) .HasForeignKey(x => x.logid); modelBuilder.Entity() .HasOne(x => x.HG_CheckQualityLogDetail) .WithMany(x => x.HG_CheckQualityLogSource) .HasForeignKey(x => x.logdetailid); modelBuilder.Entity() .HasOne(x => x.Hg_CheckQuality_Notice) .WithMany(x => x.Hg_CheckQuality_NoticeSigns) .HasForeignKey(x => x.NoticeId); base.OnModelCreating(modelBuilder); } public DbSet BAS_INNERUSER { get; set; } public DbSet BAS_INNERUSERSALT { get; set; } public DbSet SoftUser { get; set; } public DbSet WX_SZZYORDER { get; set; } public DbSet Bas_CompanyVirtual { get; set; } public DbSet Wx_Username_Resid { get; set; } public DbSet Ww_Extuser_Resid { get; set; } public DbSet RES_CUSTOMER { get; set; } public DbSet BasParameter { get; set; } public DbSet OutComplaint { get; set; } public DbSet OutComplaintOrder { get; set; } public DbSet OutComplaintFollowUp { get; set; } public DbSet OutComplaintRestore { get; set; } public DbSet InComplaint { get; set; } public DbSet InComplaintOrder { get; set; } public DbSet InComplaintFollowUp { get; set; } public DbSet InComplaintRestore { get; set; } public DbSet HolidayCalendar { get; set; } public DbSet OrderRefund { get; set; } public DbSet WX_SzzyOrderRefund { get; set; } public DbSet CsvrMessage { get; set; } public DbSet CsvrMessageType { get; set; } public DbSet BAS_ROLE { get; set; } public DbSet Bas_Role_Com { get; set; } public DbSet CmsNews { get; set; } public DbSet CmsNewsLog { get; set; } public DbSet Department { get; set; } public DbSet WxSzzyProduct { get; set; } public DbSet WX_SZZYSUBPRODUCT { get; set; } public DbSet WxComplianceConfirm { get; set; } public DbSet CsvrAiCallTask { get; set; } public DbSet CsvrAiCallTaskOrders { get; set; } public DbSet WX_SZZYORDER_AUDIT_LOG { get; set; } public DbSet SysUserProtocol { get; set; } public DbSet UserProtocolOrder { get; set; } public DbSet WX_SZZYORDER_EXTEND { get; set; } public DbSet HG_CheckQualityLog { get; set; } public DbSet HG_CheckQualityLogRelation { get; set; } public DbSet HG_CheckQualityLogDetail { get; set; } public DbSet HG_CheckQualityLogSource { get; set; } public DbSet ScreenRecord { get; set; } public DbSet WxCanopenorder { get; set; } public DbSet Hg_CheckQualityNotice { get;set; } public DbSet hg_CheckQuality_NoticeSigns { get; set; } public DbSet Employee_Department_Detail { get; set; } } }