diff --git a/docs/en/Best-Practices/Entity-Framework-Core-Integration.md b/docs/en/Best-Practices/Entity-Framework-Core-Integration.md index 4db6518201..67185d27f5 100644 --- a/docs/en/Best-Practices/Entity-Framework-Core-Integration.md +++ b/docs/en/Best-Practices/Entity-Framework-Core-Integration.md @@ -66,12 +66,7 @@ public static string Schema { get; set; } = AbpIdentityConsts.DefaultDbSchema; protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); - - builder.ConfigureIdentity(options => - { - options.TablePrefix = TablePrefix; - options.Schema = Schema; - }); + builder.ConfigureIdentity(); } ```` @@ -80,25 +75,19 @@ protected override void OnModelCreating(ModelBuilder builder) ````C# public static class IdentityDbContextModelBuilderExtensions { - public static void ConfigureIdentity( - [NotNull] this ModelBuilder builder, - Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); - var options = new IdentityModelBuilderConfigurationOptions(); - optionsAction?.Invoke(options); - builder.Entity(b => { - b.ToTable(options.TablePrefix + "Users", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); //code omitted for brevity }); builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserClaims", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserClaims", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); //code omitted for brevity }); @@ -109,17 +98,6 @@ public static class IdentityDbContextModelBuilderExtensions ```` * **Do** call `b.ConfigureByConvention();` for each entity mapping (as shown above). -* **Do** create a **configuration options** class by inheriting from the `AbpModelBuilderConfigurationOptions`. Example: - -````C# -public class IdentityModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions -{ - public IdentityModelBuilderConfigurationOptions() - : base(AbpIdentityConsts.DefaultDbTablePrefix, AbpIdentityConsts.DefaultDbSchema) - { - } -} -```` ### Repository Implementation diff --git a/docs/en/Best-Practices/MongoDB-Integration.md b/docs/en/Best-Practices/MongoDB-Integration.md index 90f7871a70..216468b71e 100644 --- a/docs/en/Best-Practices/MongoDB-Integration.md +++ b/docs/en/Best-Practices/MongoDB-Integration.md @@ -55,10 +55,7 @@ protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - modelBuilder.ConfigureIdentity(options => - { - options.CollectionPrefix = CollectionPrefix; - }); + modelBuilder.ConfigureIdentity(); } ``` @@ -73,36 +70,19 @@ public static class AbpIdentityMongoDbContextExtensions { Check.NotNull(builder, nameof(builder)); - var options = new IdentityMongoModelBuilderConfigurationOptions(); - - optionsAction?.Invoke(options); - builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "Users"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "Users"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "Roles"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "Roles"; }); } } ``` -- **Do** create a **configuration options** class by inheriting from the `AbpMongoModelBuilderConfigurationOptions`. Example: - -```c# -public class IdentityMongoModelBuilderConfigurationOptions - : AbpMongoModelBuilderConfigurationOptions -{ - public IdentityMongoModelBuilderConfigurationOptions() - : base(AbpIdentityConsts.DefaultDbTablePrefix) - { - } -} -``` - ### Repository Implementation - **Do** **inherit** the repository from the `MongoDbRepository` class and implement the corresponding repository interface. Example: 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 204eab3d6f..0aab3525da 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 @@ -8,22 +8,13 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { public static class IdentityDbContextModelBuilderExtensions { - public static void ConfigureIdentity( - [NotNull] this ModelBuilder builder, - [CanBeNull] Action optionsAction = null) + public static void ConfigureIdentity([NotNull] this ModelBuilder builder) { Check.NotNull(builder, nameof(builder)); - var options = new IdentityModelBuilderConfigurationOptions( - AbpIdentityDbProperties.DbTablePrefix, - AbpIdentityDbProperties.DbSchema - ); - - optionsAction?.Invoke(options); - builder.Entity(b => { - b.ToTable(options.TablePrefix + "Users", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); b.ConfigureAbpUser(); @@ -66,7 +57,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserClaims", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserClaims", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -82,7 +73,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserRoles", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserRoles", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -98,7 +89,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserLogins", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserLogins", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -118,7 +109,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserTokens", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserTokens", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -133,7 +124,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "Roles", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Roles", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -152,7 +143,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "RoleClaims", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "RoleClaims", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -170,7 +161,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { builder.Entity(b => { - b.ToTable(options.TablePrefix + "ClaimTypes", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "ClaimTypes", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -186,7 +177,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "OrganizationUnits", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnits", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -205,7 +196,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "OrganizationUnitRoles", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnitRoles", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -220,7 +211,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "UserOrganizationUnits", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "UserOrganizationUnits", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -235,7 +226,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore builder.Entity(b => { - b.ToTable(options.TablePrefix + "SecurityLogs", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "SecurityLogs", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); @@ -264,7 +255,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { builder.Entity(b => { - b.ToTable(options.TablePrefix + "LinkUsers", options.Schema); + b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "LinkUsers", AbpIdentityDbProperties.DbSchema); b.ConfigureByConvention(); diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityModelBuilderConfigurationOptions.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityModelBuilderConfigurationOptions.cs deleted file mode 100644 index c78496e0f5..0000000000 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityModelBuilderConfigurationOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using Volo.Abp.EntityFrameworkCore.Modeling; - -namespace Volo.Abp.Identity.EntityFrameworkCore -{ - public class IdentityModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions - { - public IdentityModelBuilderConfigurationOptions( - [NotNull] string tablePrefix, - [CanBeNull] string schema) - : base( - tablePrefix, - schema) - { - - } - } -} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/AbpIdentityMongoDbContextExtensions.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/AbpIdentityMongoDbContextExtensions.cs index d9d926a3b8..d589337593 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/AbpIdentityMongoDbContextExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/AbpIdentityMongoDbContextExtensions.cs @@ -1,50 +1,41 @@ -using System; -using Volo.Abp.MongoDB; +using Volo.Abp.MongoDB; namespace Volo.Abp.Identity.MongoDB { public static class AbpIdentityMongoDbContextExtensions { - public static void ConfigureIdentity( - this IMongoModelBuilder builder, - Action optionsAction = null) + public static void ConfigureIdentity(this IMongoModelBuilder builder) { Check.NotNull(builder, nameof(builder)); - var options = new IdentityMongoModelBuilderConfigurationOptions( - AbpIdentityDbProperties.DbTablePrefix - ); - - optionsAction?.Invoke(options); - builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "Users"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "Users"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "Roles"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "Roles"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "ClaimTypes"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "ClaimTypes"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "OrganizationUnits"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnits"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "SecurityLogs"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "SecurityLogs"; }); builder.Entity(b => { - b.CollectionName = options.CollectionPrefix + "LinkUsers"; + b.CollectionName = AbpIdentityDbProperties.DbTablePrefix + "LinkUsers"; }); } } diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/IdentityMongoModelBuilderConfigurationOptions.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/IdentityMongoModelBuilderConfigurationOptions.cs deleted file mode 100644 index d36fc17877..0000000000 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/IdentityMongoModelBuilderConfigurationOptions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using JetBrains.Annotations; -using Volo.Abp.MongoDB; - -namespace Volo.Abp.Identity.MongoDB -{ - public class IdentityMongoModelBuilderConfigurationOptions : AbpMongoModelBuilderConfigurationOptions - { - public IdentityMongoModelBuilderConfigurationOptions([NotNull] string collectionPrefix = "") - : base(collectionPrefix) - { - } - } -} \ No newline at end of file