From 3d357e46c07986aba52cbf56ea40bbb1f307b560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 11 Oct 2019 15:47:45 +0300 Subject: [PATCH] Db table prefix revision for the feature management module --- .../FeatureManagement/FeatureManagementConsts.cs | 11 ----------- .../FeatureManagementDbProperties.cs | 13 +++++++++++++ .../FeatureManagementDbContext.cs | 12 ++---------- ...ureManagementDbContextModelCreatingExtensions.cs | 5 ++++- ...ureManagementModelBuilderConfigurationOptions.cs | 4 ++-- .../IFeatureManagementDbContext.cs | 2 +- .../MongoDB/FeatureManagementMongoDbContext.cs | 9 ++------- .../FeatureManagementMongoDbContextExtensions.cs | 4 +++- ...nagementMongoModelBuilderConfigurationOptions.cs | 4 ++-- .../MongoDB/IFeatureManagementMongoDbContext.cs | 2 +- 10 files changed, 30 insertions(+), 36 deletions(-) delete mode 100644 modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementConsts.cs create mode 100644 modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementDbProperties.cs diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementConsts.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementConsts.cs deleted file mode 100644 index 0255847ba6..0000000000 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementConsts.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.FeatureManagement -{ - public static class FeatureManagementConsts - { - public const string DefaultDbTablePrefix = "Abp"; - - public const string DefaultDbSchema = null; - - public const string ConnectionStringName = "AbpFeatureManagement"; - } -} diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementDbProperties.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementDbProperties.cs new file mode 100644 index 0000000000..fb54ac2e01 --- /dev/null +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementDbProperties.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; + +namespace Volo.Abp.FeatureManagement +{ + public static class FeatureManagementDbProperties + { + public static string DbTablePrefix { get; } = AbpCommonDbProperties.DbTablePrefix; + + public static string DbSchema { get; } = AbpCommonDbProperties.DbSchema; + + public const string ConnectionStringName = "AbpFeatureManagement"; + } +} diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContext.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContext.cs index d1b685a150..af027dc9ba 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContext.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContext.cs @@ -4,13 +4,9 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { - [ConnectionStringName(FeatureManagementConsts.ConnectionStringName)] + [ConnectionStringName(FeatureManagementDbProperties.ConnectionStringName)] public class FeatureManagementDbContext : AbpDbContext, IFeatureManagementDbContext { - public static string TablePrefix { get; set; } = FeatureManagementConsts.DefaultDbTablePrefix; - - public static string Schema { get; set; } = FeatureManagementConsts.DefaultDbSchema; - public DbSet FeatureValues { get; set; } public FeatureManagementDbContext(DbContextOptions options) @@ -23,11 +19,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { base.OnModelCreating(builder); - builder.ConfigureFeatureManagement(options => - { - options.TablePrefix = TablePrefix; - options.Schema = Schema; - }); + builder.ConfigureFeatureManagement(); } } } \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs index 19abd9d6a5..eb8b18ee0a 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementDbContextModelCreatingExtensions.cs @@ -11,7 +11,10 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { Check.NotNull(builder, nameof(builder)); - var options = new FeatureManagementModelBuilderConfigurationOptions(); + var options = new FeatureManagementModelBuilderConfigurationOptions( + FeatureManagementDbProperties.DbTablePrefix, + FeatureManagementDbProperties.DbSchema + ); optionsAction?.Invoke(options); diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementModelBuilderConfigurationOptions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementModelBuilderConfigurationOptions.cs index 6567288188..035b6ed341 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementModelBuilderConfigurationOptions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/FeatureManagementModelBuilderConfigurationOptions.cs @@ -6,8 +6,8 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore public class FeatureManagementModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions { public FeatureManagementModelBuilderConfigurationOptions( - [NotNull] string tablePrefix = FeatureManagementConsts.DefaultDbTablePrefix, - [CanBeNull] string schema = FeatureManagementConsts.DefaultDbSchema) + [NotNull] string tablePrefix = "", + [CanBeNull] string schema = null) : base( tablePrefix, schema) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/IFeatureManagementDbContext.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/IFeatureManagementDbContext.cs index 0b14c47319..14abbccc5c 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/IFeatureManagementDbContext.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/IFeatureManagementDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.FeatureManagement.EntityFrameworkCore { - [ConnectionStringName(FeatureManagementConsts.ConnectionStringName)] + [ConnectionStringName(FeatureManagementDbProperties.ConnectionStringName)] public interface IFeatureManagementDbContext : IEfCoreDbContext { DbSet FeatureValues { get; set; } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContext.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContext.cs index 7689a16801..e563130d4f 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContext.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContext.cs @@ -4,21 +4,16 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.FeatureManagement.MongoDB { - [ConnectionStringName(FeatureManagementConsts.ConnectionStringName)] + [ConnectionStringName(FeatureManagementDbProperties.ConnectionStringName)] public class FeatureManagementMongoDbContext : AbpMongoDbContext, IFeatureManagementMongoDbContext { - public static string CollectionPrefix { get; set; } = FeatureManagementConsts.DefaultDbTablePrefix; - public IMongoCollection FeatureValues => Collection(); protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - modelBuilder.ConfigureFeatureManagement(options => - { - options.CollectionPrefix = CollectionPrefix; - }); + modelBuilder.ConfigureFeatureManagement(); } } } \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContextExtensions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContextExtensions.cs index 852efd0576..48c3f88dd2 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContextExtensions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContextExtensions.cs @@ -11,7 +11,9 @@ namespace Volo.Abp.FeatureManagement.MongoDB { Check.NotNull(builder, nameof(builder)); - var options = new FeatureManagementMongoModelBuilderConfigurationOptions(); + var options = new FeatureManagementMongoModelBuilderConfigurationOptions( + FeatureManagementDbProperties.DbTablePrefix + ); optionsAction?.Invoke(options); diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoModelBuilderConfigurationOptions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoModelBuilderConfigurationOptions.cs index 88361e345d..e4ba0bbc8a 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoModelBuilderConfigurationOptions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoModelBuilderConfigurationOptions.cs @@ -6,8 +6,8 @@ namespace Volo.Abp.FeatureManagement.MongoDB public class FeatureManagementMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions { public FeatureManagementMongoModelBuilderConfigurationOptions( - [NotNull] string tablePrefix = FeatureManagementConsts.DefaultDbTablePrefix) - : base(tablePrefix) + [NotNull] string collectionPrefix = "") + : base(collectionPrefix) { } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/IFeatureManagementMongoDbContext.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/IFeatureManagementMongoDbContext.cs index 5f425c1a4c..290dfbe950 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/IFeatureManagementMongoDbContext.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/IFeatureManagementMongoDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.FeatureManagement.MongoDB { - [ConnectionStringName(FeatureManagementConsts.ConnectionStringName)] + [ConnectionStringName(FeatureManagementDbProperties.ConnectionStringName)] public interface IFeatureManagementMongoDbContext : IAbpMongoDbContext { IMongoCollection FeatureValues { get; }