using DG.EntityFramework; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Logging; using Zxd.Entity.SSO; using Zxd.Entity.Zxd; using Zxd.Entity.Zxd.Order; using Zxd.Entity.Zxd.QiweiOnlePay; namespace Zxd.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.BaseProduct) .WithMany(x => x.BaseProductPackageRelations) .HasForeignKey(b => b.ProductCode) .HasPrincipalKey(b => b.Code); modelBuilder.Entity() .HasOne(b => b.BaseProductPackage) .WithMany(x => x.BaseProductPackageRelations) .HasForeignKey(b => b.PackageCode) .HasPrincipalKey(b => b.Code); modelBuilder.Entity() .HasOne(b => b.StandardProduct) .WithMany(x => x.FinishedProducts) .HasForeignKey(b => b.StandardProductId); modelBuilder.Entity() .HasKey(x => new { x.Resid, x.Userid }); modelBuilder.Entity() .HasOne(b => b.EarlyWarningTemplate) .WithMany(x => x.EarlyWarningSettings) .HasForeignKey(b => b.TemplateId); 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() .HasOne(b => b.TableField) .WithMany(x => x.FieldSettings) .HasForeignKey(b => b.FieldId); modelBuilder.Entity().HasKey(t => new { t.Resid, t.Userid, t.Deptcode }); modelBuilder.Entity().HasKey(x => new { x.ActId, x.DeptId }); modelBuilder.Entity() .HasOne(b => b.QiWeiActivity) .WithMany(x => x.QiWeiActivityDept) .HasForeignKey(b => b.ActId); modelBuilder.Entity() .HasOne(b => b.QiWeiActivity) .WithMany(x => x.QWActivityProduct) .HasForeignKey(b => b.ActId); base.OnModelCreating(modelBuilder); } public DbSet Res_Tag { get; set; } public DbSet BAS_INNERUSER { get; set; } public DbSet BAS_INNERUSERSALT { get; set; } public DbSet WX_SZZYORDER { get; set; } public DbSet Bas_CompanyChannel { get; set; } public DbSet BAS_PARAMETER { get; set; } public DbSet RES_APPLY { get; set; } public DbSet RES_RESOURCEMOBILE { get; set; } public DbSet RES_CUSTOMERUSER { get; set; } public DbSet RES_CUSTOMER { get; set; } public DbSet RES_MOBILE_MD5 { get; set; } public DbSet SMS_MESSAGE { get; set; } public DbSet SMS_MSGSUBTYPE { get; set; } public DbSet SMS_MSGTYPE_CLIENT { get; set; } public DbSet SOFT_USER { get; set; } public DbSet Soft_User_CH { get; set; } public DbSet Soft_Userinfo_Sub { get; set; } public DbSet WW_EXTUSER_RESID { get; set; } public DbSet BaseProduct { get; set; } public DbSet BaseProductPackage { get; set; } public DbSet BaseProductPackageRelation { get; set; } public DbSet CMS_QIWEI_POSTLOG { get; set; } public DbSet StandardProduct { get; set; } public DbSet FinishedProduct { get; set; } public DbSet WxSzzyProduct { get; set; } public DbSet BasCompanyChannel { get; set; } public DbSet WxSzzySubProductGift { get; set; } public DbSet WxOrderActive { get; set; } public DbSet EarlyWaning { get; set; } public DbSet EarlyWaningLog { get; set; } public DbSet EarlyWaningSetting { get; set; } public DbSet EarlyWarningTemplate { get; set; } public DbSet EarlyWarningUser { get; set; } public DbSet WX_SZZYORDER_BIND { get; set; } public DbSet Wx_SzzyOrder_HandGift { get; set; } public DbSet FieldSetting { get; set; } public DbSet TableField { get; set; } /*public DbSet FieldSetting { get; set; } public DbSet TableField { get; set; }*/ public DbSet WX_SZZYORDERDEPOSIT { get; set; } public DbSet WX_SzzyOrderRefund { get; set; } public DbSet L2SOFTORDER { get; set; } public DbSet Employee { get; set; } public DbSet WX_EMPOWER_LOG { get; set; } public DbSet EMPLOYEE_PHONE_BIND { get; set; } public DbSet EMPLOYEE_PHONE_BIND_LOG { get; set; } public DbSet EMPLOYEE_SOFT_LOG { get; set; } public DbSet EMPLOYEE_SOFT_DICT { get; set; } public DbSet WX_SZZYSUBPRODUCT { get; set; } public DbSet WxSzzySubproductCh { get; set; } public DbSet EmployeeDepartmentDetail { get; set; } public DbSet EmployeeDepartmentFull { get; set; } public DbSet Department { get; set; } public DbSet ScreenRecord { get; set; } public DbSet WxCanopenorder { get; set; } public DbSet QiWeiActivity { get; set; } public DbSet QiWeiActivityDept { get; set; } public DbSet QWActivityProduct { get; set; } } }