ABP Framework version: v5.2.0
UI type: MVCr
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes
Exception message and stack trace:
Steps to reproduce the issue:"
step1 I user abp suite generate a project ,like below
step2 Add AppUser in the domain project,and add my own properties "IdCard",like below
` public class AppUser : FullAuditedAggregateRoot
/* These properties are shared with the IdentityUser entity of the Identity module.
* Do not change these properties through this class. Instead, use Identity module
* services (like IdentityUserManager) to change them.
* So, this properties are designed as read only!
*/
public virtual Guid? TenantId { get; private set; }
public virtual string UserName { get; private set; }
public virtual string Name { get; private set; }
public virtual string Surname { get; private set; }
public virtual string Email { get; private set; }
public virtual bool EmailConfirmed { get; private set; }
public virtual string PhoneNumber { get; private set; }
public virtual bool PhoneNumberConfirmed { get; private set; }
#endregion
/* Add your own properties here. Example:
*
* public string MyProperty { get; set; }
*
* If you add a property and using the EF Core, remember these;
*
* 1. Update InfrastructureDbContext.OnModelCreating
* to configure the mapping for your new property
* 2. Update InfrastructureDbContextEfCoreEntityExtensionMappings to extend the IdentityUser entity
* and add your new property to the migration.
* 3. Use the Add-Migration to add a new database migration.
* 4. Run the .DbMigrator project (or use the Update-Database command) to apply
* schema change to the database.
*/
public string IdCard { get; set; }
private AppUser()
{
}
}`
step 3 In the EntityFrameworkCore project's DemoDbContext.cs file,I added AppUser's DbSet,and configed AppUser mapping, like below
`public class DemoDbContext : AbpDbContext
#region Entities from the modules
/* Notice: We only implemented IIdentityProDbContext and ISaasDbContext
// Identity public DbSet
// SaaS public DbSet
#endregion
public DemoDbContext(DbContextOptions
}
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder);
/* Include modules to your migration db context */
builder.ConfigurePermissionManagement();
builder.ConfigureSettingManagement();
builder.ConfigureBackgroundJobs();
builder.ConfigureAuditLogging();
builder.ConfigureIdentityPro();
builder.ConfigureIdentityServer();
builder.ConfigureFeatureManagement();
builder.ConfigureLanguageManagement();
builder.ConfigurePayment();
builder.ConfigureSaas();
builder.ConfigureTextTemplateManagement();
builder.ConfigureBlobStoring();
/*add appuser config*/
builder.Entity<AppUser>(b =>
{
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users"); //Sharing the same table "AbpUsers" with the IdentityUser
b.ConfigureByConvention();
b.ConfigureAbpUser();
/* Configure mappings for your additional properties
* Also see the OrganizationUnitSampleEfCoreEntityExtensionMappings class
*/
});
/* Configure your own tables/entities inside here */
//builder.Entity<YourEntity>(b =>
//{
// b.ToTable(DemoConsts.DbTablePrefix + "YourEntities", DemoConsts.DbSchema);
// b.ConfigureByConvention(); //auto configure for the base class props
// //...
//});
}`
step4 In the DemoEfcoreEntityExtensionMappings.cs I set the ObjectExtensionManager like below:
` public static void Configure() { DemoGlobalFeatureConfigurator.Configure(); DemoModuleExtensionConfigurator.Configure();
OneTimeRunner.Run(() =>
{
/* You can configure extra properties for the
* entities defined in the modules used by your application.
*
* This class can be used to map these extra properties to table fields in the database.
*
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING.
* USE DemoModuleExtensionConfigurator CLASS (in the Domain.Shared project)
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES
*
* Example: Map a property to a table field:
ObjectExtensionManager.Instance
.MapEfCoreProperty<IdentityUser, string>(
"MyProperty",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.HasMaxLength(128);
}
);
* See the documentation for more:
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
*/
ObjectExtensionManager.Instance
.MapEfCoreProperty<IdentityUser, string>(
"IdCard",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.HasMaxLength(19);
}
);
});
}`
step5 When I run the *,DbMigrator project,it says "Cannot use table 'AbpUsers' for entity type 'IdentityUser' since it is being used for entity type 'AppUser' and potentially other entity types, but there is no linking relationship. Add a foreign key to 'IdentityUser' on the primary key properties and pointing to the primary key on another entity type mapped to 'AbpUsers'." like below: