From d31fba1d047c7c2653571fd7a62d34d8360fd86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 10 Dec 2020 20:29:23 +0300 Subject: [PATCH] CmsUsers table should only be available if any feature enabled. --- .../CmsKitDbContextModelCreatingExtensions.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 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 adda59c3e2..b81704034a 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 @@ -1,4 +1,5 @@ using System; +using System.Linq; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; @@ -27,16 +28,20 @@ namespace Volo.CmsKit.EntityFrameworkCore optionsAction?.Invoke(options); - builder.Entity(b => + //TODO: What if only CMSKit Pro features are enabled? This is kinda workaround for now + if (GlobalFeatureManager.Instance.Modules.CmsKit().GetFeatures().Any(f => f.IsEnabled)) { - b.ToTable(options.TablePrefix + "Users", options.Schema); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Users", options.Schema); - b.ConfigureByConvention(); - b.ConfigureAbpUser(); + b.ConfigureByConvention(); + b.ConfigureAbpUser(); - b.HasIndex(x => new {x.TenantId, x.UserName}); - b.HasIndex(x => new {x.TenantId, x.Email}); - }); + b.HasIndex(x => new {x.TenantId, x.UserName}); + b.HasIndex(x => new {x.TenantId, x.Email}); + }); + } if (GlobalFeatureManager.Instance.IsEnabled()) { @@ -86,7 +91,7 @@ namespace Volo.CmsKit.EntityFrameworkCore r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength); r.HasIndex(x => new {x.TenantId, x.EntityType, x.EntityId, x.CreatorId}); - }); + }); } } }