after use abp suite to add a navigation property (identityuser)to a entity then I get a error in the host. Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
If you're creating a bug/problem report, please include followings:
ABP Framework version: v7.2.2
UI type: Blazor
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes / no
*Exception message and stack trace
[00:36:39 ERR] The entity type 'ExtraPropertyDictionary' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943. 2023-06-30 08:36:39 System.InvalidOperationException: The entity type 'ExtraPropertyDictionary' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943. 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ValidateNonNullPrimaryKeys(IModel model, IDiagnosticsLogger
1 logger) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.Validate(IModel model, IDiagnosticsLogger
1 logger) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelValidator.Validate(IModel model, IDiagnosticsLogger1 logger) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerModelValidator.Validate(IModel model, IDiagnosticsLogger
1 logger) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger1 validationLogger) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model() 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at ResolveService(ILEmitResolverBuilderRuntimeContext, ServiceProviderEngineScope) 2023-06-30 08:36:39 at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) 2023-06-30 08:36:39 at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices() 2023-06-30 08:36:39 at Microsoft.EntityFrameworkCore.DbContext.get_ChangeTracker() 2023-06-30 08:36:39 at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.Initialize(AbpEfCoreDbContextInitializationContext initializationContext) 2023-06-30 08:36:39 at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.CreateDbContextAsync(IUnitOfWork unitOfWork, String connectionStringName, String connectionString) 2023-06-30 08:36:39 at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider
1.GetDbContextAsync() 2023-06-30 08:36:39 at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.GetDbSetAsync() 2023-06-30 08:36:39 at WeChatMP.Mps.EfCoreMpRepository.GetQueryForNavigationPropertiesAsync() in D:\CP_A\aspnet-core\modules\WeChatMP\src\WeChatMP.EntityFrameworkCore\Mps\EfCoreMpRepository.cs:line 57 2023-06-30 08:36:39 at WeChatMP.Mps.EfCoreMpRepository.GetCountAsync(String filterText, String mpName, String appId, String appsecret, String user, String password, String remark, Nullable
1 identityUserId, CancellationToken cancellationToken) in D:\CP_A\aspnet-core\modules\WeChatMP\src\WeChatMP.EntityFrameworkCore\Mps\EfCoreMpRepository.cs:line 118 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) 2023-06-30 08:36:39 at WeChatMP.Mps.MpsAppService.GetListAsync(GetMpsInput input) in D:\CP_A\aspnet-core\modules\WeChatMP\src\WeChatMP.Application\Mps\MpsAppService.cs:line 43 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) 2023-06-30 08:36:39 at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) 2023-06-30 08:36:39 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() 2023-06-30 08:36:39 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2023-06-30 08:36:39 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) 2023-06-30 08:36:39 at lambda_method5070(Closure, Object) 2023-06-30 08:36:39 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) 2023-06-30 08:36:39 at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) 2023-06-30 08:36:39 at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.*Steps to reproduce the issue *:"
creat a solution using application template
creat a module and add to the solution
creat a entity and add a navigation property(indentityuser)
update dabase
then the error shows
6 Answer(s)
-
0
Hi,
You can check this: https://github.com/abpframework/abp/issues/11079#issuecomment-1001492543
-
0
Hi, Already checked this.
-
0
Hi,
Could you share a project that can reproduce the problem with me? shiwei.liang@volosoft.com I will check it.
-
0
Hi,
You can try:
- Remove all migration files
- Remove
CPA/Migrations
- Update DbContext:
[ReplaceDbContext(typeof(IIdentityProDbContext))] [ReplaceDbContext(typeof(ISaasDbContext))] [ReplaceDbContext(typeof(IWeChatMPDbContext))] [ConnectionStringName("Default")] public class CP_ADbContext : AbpDbContext<CP_ADbContext>, IIdentityProDbContext, ISaasDbContext, IWeChatMPDbContext { /* Add DbSet properties for your Aggregate Roots / Entities here. */ #region Entities from the modules /* Notice: We only implemented IIdentityProDbContext and ISaasDbContext * and replaced them for this DbContext. This allows you to perform JOIN * queries for the entities of these modules over the repositories easily. You * typically don't need that for other modules. But, if you need, you can * implement the DbContext interface of the needed module and use ReplaceDbContext * attribute just like IIdentityProDbContext and ISaasDbContext. * * More info: Replacing a DbContext of a module ensures that the related module * uses this DbContext on runtime. Otherwise, it will use its own DbContext class. */ // Identity public DbSet<IdentityUser> Users { get; set; } public DbSet<IdentityRole> Roles { get; set; } public DbSet<IdentityClaimType> ClaimTypes { get; set; } public DbSet<OrganizationUnit> OrganizationUnits { get; set; } public DbSet<IdentitySecurityLog> SecurityLogs { get; set; } public DbSet<IdentityLinkUser> LinkUsers { get; set; } public DbSet<IdentityUserDelegation> UserDelegations { get; } // SaaS public DbSet<Tenant> Tenants { get; set; } public DbSet<Edition> Editions { get; set; } public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; } // WeChatMP public DbSet<Mp> Mps { get; set; } #endregion public CP_ADbContext(DbContextOptions<CP_ADbContext> options) : base(options) { } 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.ConfigureOpenIddictPro(); builder.ConfigureFeatureManagement(); builder.ConfigureLanguageManagement(); builder.ConfigureSaas(); builder.ConfigureTextTemplateManagement(); builder.ConfigureBlobStoring(); builder.ConfigureGdpr(); builder.ConfigureWeChatMP(); } }
- Re-create the migration file.
-
0
Hi, I Have tried all the setps:
Remove all migration files
Remove CPA/Migrations
Update DbContext:
Re-create the migration file.
Delete database
update-database
.still get the same error. and the menu doesn't show after login.need to refresh the page.
-
0
Hi,
I shared the modified project to your email