From ff05ece058acf4007bee5c7c9cfea914a9f8a2a3 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 5 Jan 2021 17:31:45 +0300 Subject: [PATCH] feature checks added. --- .../CmsKitDbContextModelCreatingExtensions.cs | 105 ++++++++++-------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index 8d32de7958..5e823abf11 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -97,57 +97,66 @@ namespace Volo.CmsKit.EntityFrameworkCore }); } - builder.Entity(b => + if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "Contents", options.Schema); - - b.ConfigureByConvention(); - - b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); - b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); - - b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); - }); - - builder.Entity(b => - { - b.ToTable(options.TablePrefix + "Tags", options.Schema); - - b.ConfigureByConvention(); - - b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); - b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); - - b.HasIndex(x => new { x.TenantId, x.Name }); - }); - - builder.Entity(b => + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Contents", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); + b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); + + b.HasIndex(x => new {x.TenantId, x.EntityType, x.EntityId}); + }); + } + + if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "EntityTags", options.Schema); - - b.ConfigureByConvention(); - - b.HasKey(x => new { x.EntityId, x.TagId }); - - b.Property(x => x.EntityId).IsRequired(); - b.Property(x => x.TagId).IsRequired(); - - b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId }); - }); - - builder.Entity(b => + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Tags", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); + b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); + + b.HasIndex(x => new {x.TenantId, x.Name}); + }); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "EntityTags", options.Schema); + + b.ConfigureByConvention(); + + b.HasKey(x => new {x.EntityId, x.TagId}); + + b.Property(x => x.EntityId).IsRequired(); + b.Property(x => x.TagId).IsRequired(); + + b.HasIndex(x => new {x.TenantId, x.EntityId, x.TagId}); + }); + } + + if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "Pages", options.Schema); - - b.ConfigureByConvention(); - - b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); - b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength); - b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength); - - b.HasIndex(x => new { x.TenantId, x.Url }); - }); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Pages", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); + b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength); + b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength); + + b.HasIndex(x => new {x.TenantId, x.Url}); + }); + } } } }