| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System.Data.Common;
- using System.Data.Entity;
- using System.Data.Entity.ModelConfiguration.Conventions;
- using WePlatform.Authorization.Roles;
- using WePlatform.Authorization.Users;
- using WePlatform.BaseInfo;
- using WePlatform.MultiTenancy;
- using IwbZero.EntityFramework;
- using WePlatform.ThirdPartySystem;
- using WePlatform.WeBase;
- using WePlatform.WeLib;
- using WePlatform.WeLib.Knowledge;
- using WePlatform.WeModel;
- namespace WePlatform.EF
- {
- public class WePlatformDbContext : IwbZeroDbContext<Tenant, Role, User>
- {
- //TODO: Define an IDbSet for your Entities...
- #region WE
- public IDbSet<ThirdPartySystemInfo> ThirdPartySystemInfos { get; set; }
- public IDbSet<SceneCategoryInfo> SceneCategoryInfos { get; set; }
- public IDbSet<BehaviorRoleInfo> BehaviorRoleInfos { get; set; }
- public IDbSet<RoleRelateCategoryInfo> RoleRelateCategoryInfos { get; set; }
- public IDbSet<EnvironResourceInfo> EnvironResourceInfos { get; set; }
- public IDbSet<EnvironResourceRelatedInfo> EnvironResourceRelatedInfos { get; set; }
- public IDbSet<EngineInfo> EngineInfos { get; set; }
- public IDbSet<EngineModelInfo> EngineModelInfos { get; set; }
- public IDbSet<EvalModelInfo> EvalModelInfos { get; set; }
- public IDbSet<EvalTargetInfo> EvalTargetInfos { get; set; }
- public IDbSet<EvalReportTemplateInfo> EvalReportTemplateInfos { get; set; }
- public IDbSet<EngineComponentInfo> EngineComponentInfos { get; set; }
- public IDbSet<GuideInfo> GuideInfos { get; set; }
- public IDbSet<GuideRelatedInfo> GuideRelatedInfos { get; set; }
- public IDbSet<KnowledgeInfo> KnowledgeInfos { get; set; }
- public IDbSet<EmergencyPlanInfo> EmergencyPlanInfos { get; set; }
- public IDbSet<KnowledgeRelatePlanInfo> KnowledgeRelatePlanInfos { get; set; }
- public IDbSet<EmergencyPlanContentInfo> EmergencyPlanContentInfos { get; set; }
- public IDbSet<EmergencyResourceInfo> EmergencyResourceInfos { get; set; }
- public IDbSet<BehaviorInfo> BehaviorInfos { get; set; }
- public IDbSet<BehaviorRelateRoleInfo> BehaviorRelateRoleInfos { get; set; }
- public IDbSet<BehaviorKnowledgeInfo> BehaviorKnowledgeInfos { get; set; }
- public IDbSet<SceneInfo> SceneInfos { get; set; }
- public IDbSet<SceneBehaviorInfo> SceneBehaviorInfos { get; set; }
- public IDbSet<SceneFlowInfo> SceneFlowInfos { get; set; }
- public IDbSet<PackageInfo> PackageInfos { get; set; }
- public IDbSet<PackageXmlInfo> PackageXmlInfos { get; set; }
- #endregion
- /* NOTE:
- * Setting "Default" to base class helps us when working migration commands on Package Manager Console.
- * But it may cause problems when working Migrate.exe of EF. If you will apply migrations on command line, do not
- * pass connection string name to base classes. ABP works either way.
- */
- public IDbSet<SysAttachFile> SysAttachFiles { get; set; }
- public IDbSet<SysState> SysStates { get; set; }
- public IDbSet<SysFunction> SysFunctions { get; set; }
- public IDbSet<SysHelp> SysHelps { get; set; }
- public WePlatformDbContext()
- : base("Default")
- {
- }
- /* NOTE:
- * This constructor is used by ABP to pass connection string defined in WePlatformDataModule.PreInitialize.
- * Notice that, actually you will not directly create an instance of WePlatformDbContext since ABP automatically handles it.
- */
- public WePlatformDbContext(string nameOrConnectionString)
- : base(nameOrConnectionString)
- {
- }
- //This constructor is used in tests
- public WePlatformDbContext(DbConnection existingConnection)
- : base(existingConnection, false)
- {
- }
- public WePlatformDbContext(DbConnection existingConnection, bool contextOwnsConnection)
- : base(existingConnection, contextOwnsConnection)
- {
- }
-
- protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- //---关闭级联删除
- // 禁用一对多级联删除
- modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
- // 禁用多对多级联删除
- modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
- }
- }
- }
|