diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs index 01adfad531..a2a63062d3 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { public static void ConfigureIdentity( [NotNull] this ModelBuilder builder, - Action optionsAction = null) + [CanBeNull] Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementConsts.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementConsts.cs deleted file mode 100644 index 518a06c244..0000000000 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementConsts.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.SettingManagement -{ - public static class AbpSettingManagementConsts - { - public const string DefaultDbTablePrefix = "Abp"; - - public const string DefaultDbSchema = null; - - public const string ConnectionStringName = "AbpSettingManagement"; - } -} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDbProperties.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDbProperties.cs new file mode 100644 index 0000000000..6ffa8c192b --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDbProperties.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; + +namespace Volo.Abp.SettingManagement +{ + public static class AbpSettingManagementDbProperties + { + public static string DbTablePrefix { get; } = AbpCommonDbProperties.DbTablePrefix; + + public static string DbSchema { get; } = AbpCommonDbProperties.DbSchema; + + public const string ConnectionStringName = "AbpSettingManagement"; + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs index a24c07b350..fea486a163 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/ISettingManagementDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.SettingManagement.EntityFrameworkCore { - [ConnectionStringName(AbpSettingManagementConsts.ConnectionStringName)] + [ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)] public interface ISettingManagementDbContext : IEfCoreDbContext { DbSet Settings { get; set; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs index 7db9bf2bf2..e85bcd21cc 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs @@ -4,13 +4,9 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.SettingManagement.EntityFrameworkCore { - [ConnectionStringName(AbpSettingManagementConsts.ConnectionStringName)] + [ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)] public class SettingManagementDbContext : AbpDbContext, ISettingManagementDbContext { - public static string TablePrefix { get; set; } = AbpSettingManagementConsts.DefaultDbTablePrefix; - - public static string Schema { get; set; } = AbpSettingManagementConsts.DefaultDbSchema; - public DbSet Settings { get; set; } public SettingManagementDbContext(DbContextOptions options) @@ -23,7 +19,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore { base.OnModelCreating(builder); - builder.ConfigureSettingManagement(TablePrefix, Schema); + builder.ConfigureSettingManagement(); } } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs index 5c8c68b4f4..e95cb9791a 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs @@ -1,26 +1,42 @@ -using JetBrains.Annotations; +using System; +using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.SettingManagement.EntityFrameworkCore { + public class SettingManagementModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions + { + public SettingManagementModelBuilderConfigurationOptions( + [NotNull] string tablePrefix, + [CanBeNull] string schema) + : base( + tablePrefix, + schema) + { + + } + } + public static class SettingManagementDbContextModelBuilderExtensions { //TODO: Instead of getting parameters, get a action of SettingManagementModelBuilderConfigurationOptions like other modules public static void ConfigureSettingManagement( [NotNull] this ModelBuilder builder, - [CanBeNull] string tablePrefix = AbpSettingManagementConsts.DefaultDbTablePrefix, - [CanBeNull] string schema = AbpSettingManagementConsts.DefaultDbSchema) + [CanBeNull] Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); - if (tablePrefix == null) - { - tablePrefix = ""; - } + var options = new SettingManagementModelBuilderConfigurationOptions( + AbpSettingManagementDbProperties.DbTablePrefix, + AbpSettingManagementDbProperties.DbSchema + ); + + optionsAction?.Invoke(options); builder.Entity(b => { - b.ToTable(tablePrefix + "Settings", schema); + b.ToTable(options.TablePrefix + "Settings", options.Schema); b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLength).IsRequired(); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs index 0bf3894e7c..357ab0bfe3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/ISettingManagementMongoDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.SettingManagement.MongoDB { - [ConnectionStringName(AbpSettingManagementConsts.ConnectionStringName)] + [ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)] public interface ISettingManagementMongoDbContext : IAbpMongoDbContext { IMongoCollection Settings { get; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs index 7cc388982d..ada3a8100f 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContext.cs @@ -4,21 +4,16 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.SettingManagement.MongoDB { - [ConnectionStringName(AbpSettingManagementConsts.ConnectionStringName)] + [ConnectionStringName(AbpSettingManagementDbProperties.ConnectionStringName)] public class SettingManagementMongoDbContext : AbpMongoDbContext, ISettingManagementMongoDbContext { - public static string CollectionPrefix { get; set; } = AbpSettingManagementConsts.DefaultDbTablePrefix; - public IMongoCollection Settings => Collection(); protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - modelBuilder.ConfigureSettingManagement(options => - { - options.CollectionPrefix = CollectionPrefix; - }); + modelBuilder.ConfigureSettingManagement(); } } } \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs index 057eebf7a4..349341b5d3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoDbContextExtensions.cs @@ -7,11 +7,13 @@ namespace Volo.Abp.SettingManagement.MongoDB { public static void ConfigureSettingManagement( this IMongoModelBuilder builder, - Action optionsAction = null) + Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); - var options = new SettingManagementMongoModelBuilderConfigurationOptions(); + var options = new SettingManagementMongoModelBuilderConfigurationOptions( + AbpSettingManagementDbProperties.DbTablePrefix + ); optionsAction?.Invoke(options); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoModelBuilderConfigurationOptions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoModelBuilderConfigurationOptions.cs index aad41fc470..a603e1e204 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoModelBuilderConfigurationOptions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/SettingManagementMongoModelBuilderConfigurationOptions.cs @@ -5,7 +5,8 @@ namespace Volo.Abp.SettingManagement.MongoDB { public class SettingManagementMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions { - public SettingManagementMongoModelBuilderConfigurationOptions([NotNull] string tablePrefix = AbpSettingManagementConsts.DefaultDbTablePrefix) + public SettingManagementMongoModelBuilderConfigurationOptions( + [NotNull] string tablePrefix = "") : base(tablePrefix) { }