ComplianceServer/code/Hg.Core.EntityFramework/ZxdDbContext.cs

144 lines
5.8 KiB
C#

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