ABP Framework version: v8.0.4
UI Type: Angular
Database System: EF Core (SQL Server)
Tiered (for MVC) or Auth Server Separated (for Angular): yes
Exception message and full stack trace:
EXCEPTION: System.InvalidOperationException: The instance of entity type 'IdentityUserLogin' cannot be tracked because another instance with the same key value for {'UserId', 'LoginProvider'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values. at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap
1.ThrowIdentityConflict(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap1.Add(TKey key, InternalEntityEntry entry, Boolean updateDuplicate) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap
1.Add(TKey key, InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NullableKeyIdentityMap1.Add(InternalEntityEntry entry) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges, Boolean modifyProperties) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges, Boolean modifyProperties, Nullable
1 forceStateWhenUnknownKey, Nullable1 fallbackState) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode
1 node)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode1 node, Func
2 handleNode)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState targetState, EntityState storeGeneratedWithKeySetTargetState, Boolean forceStateWhenUnknownKey)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.NavigationCollectionChanged(InternalEntityEntry entry, INavigationBase navigationBase, IEnumerable1 added, IEnumerable
1 removed)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryNotifier.NavigationCollectionChanged(InternalEntityEntry entry, INavigationBase navigationBase, IEnumerable1 added, IEnumerable
1 removed)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectNavigationChange(InternalEntityEntry entry, INavigationBase navigationBase)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.LocalDetectChanges(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectChanges(IStateManager stateManager)
at Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.DetectChanges()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_Local() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository
2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.Identity.IdentityUserStore.UpdateAsync(IdentityUser user, CancellationToken cancellationToken) at Microsoft.AspNetCore.Identity.UserManager
1.UpdateUserAsync(TUser user)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Microsoft.AspNetCore.Identity.UserManager
1.AddLoginAsync(TUser user, UserLoginInfo login)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.Account.Public.Web.Pages.Account.LoginModel.OnGetExternalLoginCallbackAsync(String remoteError) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at company.Product.Common.AspNetCore.logMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in /src/src/company.Product.Common.AspNetCore/logMiddleware.cs:line 42 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpOpenIddictMiddlewareExtension.<>c__DisplayClass0_0.<<UseAbpOpenIddictValidation>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
Steps to reproduce the issue: After updating to ABP 8.0.4, we have a problem logging in with External Authentication, we get a 500 error. Any ideas?
After updating from v6.x we are now trying to generate the Angular proxies, but we are getting:
Cannot read properties of null (reading 'replace')
when executing:
abp generate-proxy -t ng -u http://localhost:5101
We can reach the api-definition document on: http://localhost:5101/api/abp/api-definition
Any pointers how to troubleshoot this? Does the abp cli generate logs or something we can use?
We are using ICancellationTokenProvider for our repositories with the GetCancellationToken() method, so we don't have to sprinkle the CancellationTokens into every method. This works well with the HttpContext Token Provider.
We would like to do the same thing with Background Workers (we are using HangfireBackgroundWorkerBase) - but we are not sure how to... any pointers? Or do we need to convert our Repositories to take CancellationTokens as parameters for this to work properly?
Thanks
I haven't found the answer to this... with Identity Server it was possible to use Azure AD to log into ABP. Is this still possible while using OpenIDDict?
We are in the process of migrating from IDS to OpenIDDict, but we haven't found a documented answer for this yet...
Thanks
We have upgraded to 5.1.1 and one of the features we're interested in is Impersonation. This worked well in aspnetzero for us. We have added the "Impersonation" Claim Type to the _App application.
However, we can't see any sign of Impersonation in the Angular UI. There are no permissions to set, there are no impersonation options.
We have looked at the documentation here: https://docs.abp.io/en/commercial/latest/modules/account/impersonation#angular
The documentation is fairly thin, some more description on HOW to impersonate users would also be great.
Hi
Using abp 4.4 with EF/SQL Server.
We don't like using "Id" as the column name for our entities, so we are using this workaround: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/586#issuecomment-135599562
It does work fine for entities that don't have a Guid Key. Once the Key is Guid, things start to break down. EF throws errors that the "Id column was not found".
We have found the cause of it, it's AbpDbContext.TrySetGuidId and AbpDbContext.ConfigureValueGenerated
We have also found a suitable workaround by overriding these functions like this:
protected override void TrySetGuidId(EntityEntry entry, IEntity<Guid> entity)
{
if (entry.Metadata.FindProperty("Id") == null)
{
// Ignore this, it's because we have removed the Id property.
return;
}
base.TrySetGuidId(entry, entity);
}
protected override void ConfigureValueGenerated<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)
where TEntity : class
{
if (!typeof(IEntity<Guid>).IsAssignableFrom(typeof(TEntity)))
{
return;
}
// Ignore if Id has NotMapped attribute
var type = mutableEntityType.ClrType;
var propertyInfo = type.GetProperty("Id", BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance);
if (propertyInfo != null)
{
var attribute = propertyInfo.GetCustomAttribute(typeof(NotMappedAttribute));
if (attribute != null)
{
return;
}
}
base.ConfigureValueGenerated<TEntity>(modelBuilder, mutableEntityType);
}
The configureValueGenerated function does create the property when it does not exist. So even when it was excluded with [NotMapped], this line from AbpDbContext adds it: var idPropertyBuilder = modelBuilder.Entity().Property(x => ((IEntity)x).Id);
(Note the documentation saying that "Returns an object that ban be used to configure a property of the entity type. If the specified property is not already part of the model, it will be added.")
So the Id property is added to the model if the type is Guid.
Then the TrySetGuidId also expects the Id property to be there:
var idProperty = entry.Property("Id").Metadata.PropertyInfo;
Which of course fails, too.
Now to the question:
Thanks Michel
We are using docker to develop a solution using abp. This means docker will often need to download ABP packages. We often get the following error with multiple packages, sometimes for hours, and then the error suddenly disappears. We don't know what to do currently and would like to ask for help.
#132 43.50 /usr/share/dotnet/sdk/5.0.400/NuGet.targets(131,5): error : Failed to download package 'Volo.Abp.Account.Pro.Shared.Application.4.4.2' from 'https://nuget.abp.io/redacted/v3/package/volo.abp.account.pro.shared.application/4.4.2/volo.abp.account.pro.shared.application.4.4.2.nupkg'. [/src/src/company.product.AgentHttpApi.Host/company.product.AgentHttpApi.Host.csproj] #132 43.50 /usr/share/dotnet/sdk/5.0.400/NuGet.targets(131,5): error : Response status code does not indicate success: 409 (Conflict). [/src/src/company.product.AgentHttpApi.Host/company.product.AgentHttpApi.Host.csproj]
The step that provokes this is: RUN dotnet restore "src/company.product.AgentHttpApi.Host/company.product.AgentHttpApi.Host.csproj" --configfile "nuget.config"
Any idea what could cause this?
Thanks Michel
Hi
We are trying to make the DbMigrator project aware of different environments by using an appsettings.json per environment. This is usually straight forward by just creating appsettings.<Environment>.json file.
Unfortunately in the DbMigrator project this does not seem to work. While troubleshooting I have injected IConfiguration into the DbMigratorHostedService, and I did a Console.WriteLIne(_configuration.GetConnectionString("Default")); in the StartAsync method. Surprisingly, THIS WORKS and it gives the correct connection string! However, strangely it executes the DbMigration on the connection string from the original appsettings.json, instead of the one from IConfiguration..... I can't explain why. I can change the appsettings.json, and it connects to a different database, so it's definitely using that one.
Any ideas?
Thanks Michel
Using Angular with separate IdentityServer. Tenants resolve using subdomain tenant resolver.
I keep running into issues. Current issue: Got subdomain identity server, {0}.identity.domain.com The Http Api however has "identity.domain.com" as Authority, which obviously doesn't work.
I found this that talks about a Wildcard Issuer Validator: https://github.com/abpframework/abp/pull/8884 However the code is not available anymore on Github, only a nuget package (that's not cutting it for me...)
Is there any official guideance on this? Maybe just somehow who creates a new project and configures it that it works with subdomains, angular and separate identity server and documents all the relevant settings in a blog post or so? :) This can't be such an unusual scenario, but I'm really struggling.
Hello
We are looking into using ABP.IO for our own platform. We would have multiple "products" (applications) which are each multi-tenant, and we are looking into providing a shared identity for them, so we/customers can use a single login (SSO) with all applications.
Is this something that ABP (Commercial) can do? Can you use a single identity server with multiple (ABP) applications?
Thanks MIchel