- ABP Framework version: v7.4.2
- UI Type: Angular
- Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace: System.InvalidCastException: Column 'ConcurrencyStamp' is null.
at Npgsql.ThrowHelper.ThrowInvalidCastException_NoValue(FieldDescription field)
at Npgsql.NpgsqlDataReader.GetFieldValue[T](Int32 ordinal)
at lambda_method2812(Closure, DbDataReader, Int32[])
at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.BufferedDataRecord.ReadObject(DbDataReader reader, Int32 ordinal, ReaderColumn column)
at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.BufferedDataRecord.ReadRow()
at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.BufferedDataRecord.InitializeAsync(DbDataReader reader, IReadOnlyList
1 columns, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.InitializeAsync(IReadOnlyList
1 columns, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.InitializeAsync(IReadOnlyList1 columns, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable
1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func
4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable
1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Volo.Abp.OpenIddict.Scopes.EfCoreOpenIddictScopeRepository.FindByNamesAsync(String[] names, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) at Volo.Abp.OpenIddict.Scopes.AbpOpenIddictScopeStore.FindByNamesAsync(ImmutableArray1 names, CancellationToken cancellationToken)+MoveNext() at Volo.Abp.OpenIddict.Scopes.AbpOpenIddictScopeStore.FindByNamesAsync(ImmutableArray
1 names, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() at Volo.Abp.OpenIddict.Scopes.AbpOpenIddictScopeCache.FindByNamesAsync(ImmutableArray1 names, CancellationToken cancellationToken)+MoveNext() at Volo.Abp.OpenIddict.Scopes.AbpOpenIddictScopeCache.FindByNamesAsync(ImmutableArray
1 names, CancellationToken cancellationToken)+MoveNext() at Volo.Abp.OpenIddict.Scopes.AbpOpenIddictScopeCache.FindByNamesAsync(ImmutableArray1 names, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() at OpenIddict.Core.OpenIddictScopeManager
1.<>c__DisplayClass20_0.<<FindByNamesAsync>g__ExecuteAsync|0>d.MoveNext() --- End of stack trace from previous location --- at OpenIddict.Core.OpenIddictScopeManager1.<>c__DisplayClass20_0.<<FindByNamesAsync>g__ExecuteAsync|0>d.MoveNext() --- End of stack trace from previous location --- at OpenIddict.Core.OpenIddictScopeManager
1.<>c__DisplayClass20_0.<<FindByNamesAsync>g__ExecuteAsync|0>d.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateScopes.HandleAsync(ValidateTokenRequestContext context) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateScopes.HandleAsync(ValidateTokenRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateTokenRequest.HandleAsync(ProcessRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.HandleRequestAsync() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at SCV.Litmus.Shared.DecryptHttpHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\Repository\SCV.Litmus\aspnet-core\shared\SCV.Litmus.Shared\Middleware\DecryptHttpHeadersMiddleware.cs:line 51 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at SCV.Litmus.Shared.DecryptHttpRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\Repository\SCV.Litmus\aspnet-core\shared\SCV.Litmus.Shared\Middleware\DecryptHttpRequestMiddleware.cs:line 103 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>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.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at SCV.Litmus.LitmusIdentityServerModule.<>c.<<OnApplicationInitialization>b__3_1>d.MoveNext() in C:\Repository\SCV.Litmus\aspnet-core\microservices\SCV.Litmus.IdentityServer\LitmusIdentityServerModule.cs:line 253 --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
HEADERS
Accept: application/json, text/plain, / Accept-Encoding: gzip, deflate, br Accept-Language: en Connection: keep-alive Content-Length: 188 Content-Type: application/x-www-form-urlencoded Cookie: .AspNetCore.Culture=c%3Den%7Cuic%3Den; __tenant=d1be844b-d3a2-031a-f036-39f5d4380239 Host: localhost:44350 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 authority: https://localhost:44350/ __tenant: {valid tenant Id} __tname: {valid tenant name} sec-fetch-site: same-site sec-fetch-mode: cors sec-fetch-dest: empty Postman-Token: d948f23b-4e49-4422-9bc0-6aab0b6f58c1 X-Correlation-Id: c77a5c849bfd412c8fc5b3b52d4f3c34
- Steps to reproduce the issue:
-
- Calling the API to get the token : https://localhost:44350/connect/token from identity server
-
- Getting above errors in custom middlewares used for encrypt and decrypt the request headers
-
- Found that its happening for all the entities where "ConcurrencyStamp" is null in DB
5 Answer(s)
-
0
-
0
Hi,
The
ConcurrencyStamp
should not be NULL by default.You can try to manually assign values to
ConcurrencyStamp
in the database and test again.Thanks for the suggestions. I was just wondering anything got changed in V7.4.2, because it was working fine with null values in previous version and its happening for all the tables with concurrencystamp and extraproperties column. To update manually is not valid solution considering there are so many tables with those columns.
Could you suggest please.
-
0
Hi,
The
ConcurrencyStamp
should never be null, because ABP will set it up internally. I'm wondering why your database value isNULL
. See: https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs#L533I think you need to check your database table.
- https://github.com/npgsql/efcore.pg/issues/884#issuecomment-607546356
- https://stackoverflow.com/questions/73563589/system-invalidcastexception-c
-
0
Hi,
The
ConcurrencyStamp
should never be null, because ABP will set it up internally. I'm wondering why your database value isNULL
.
See: https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs#L533I think you need to check your database table.
- https://github.com/npgsql/efcore.pg/issues/884#issuecomment-607546356
- https://stackoverflow.com/questions/73563589/system-invalidcastexception-c
Understood that ABP handles inserting the values and ConcurrencyStamp would never be null. But the columns allows null as they are nullable fields. so reading those values should not cause any issue right?
Could you suggest any workaround, instead of manually find all the tables which have null values for these columns and update.
-
0
You can try to use this:
protected override void OnModelCreating(ModelBuilder builder) { ..... foreach (var entityType in builder.Model.GetEntityTypes()) { if (typeof(IHasConcurrencyStamp).IsAssignableFrom(entityType.ClrType)) { builder.Entity(entityType.ClrType).Property(nameof(IHasConcurrencyStamp.ConcurrencyStamp)).IsRequired(false); } } }
And add a new migration file.