question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abp.Domain.Uow.AbpDbConcurrencyException UserAppService_Link_Tests

See original GitHub issue

GitHub Issues

bug

  • Abp package version. 3.7.2
  • Base framework: .Net Core
  • Exception message and stack trace if available. Message: Abp.Domain.Uow.AbpDbConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values. ---- Abp.Domain.Uow.AbpDbConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values. -------- Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values.

Result StackTrace: at ABP.EntityFrameworkCore.DataCentralDbContext.<SaveChangesAsync>d__1220.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesInDbContextAsync>d__20.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesAsync>d__12.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<CompleteUowAsync>d__14.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Domain.Uow.UnitOfWorkBase.<CompleteAsync>d__57.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Domain.Uow.UnitOfWorkInterceptor.<>c__DisplayClass6_0.<<PerformAsyncUow>b__2>d.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserStore2.<UpdateAsync>d__36.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Identity.UserManager1.<UpdateUserAsync>d__174.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Identity.UserManager1.<SetLockoutEnabledAsync>d__138.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserManager2.<CreateAsync>d__33.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at ABP.Tests.Authorization.Users.UserAppService_Link_Tests.<CreateTestUsersForAccountLinkingAsync>d__12.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at ABP.Tests.Authorization.Users.UserAppService_Link_Tests.<Should_Link_User_To_Already_Linked_User>d__9.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ----- Inner Stack Trace ----- at Abp.EntityFrameworkCore.AbpDbContext.<SaveChangesAsync>d__49.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.<SaveChangesAsync>d__98.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at ABP.EntityFrameworkCore.DataCentralDbContext.<SaveChangesAsync>d__1220.MoveNext() ----- Inner Stack Trace ----- at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable1.ThrowUpdateConcurrencyException(IUpdateEntry entry, Dictionary2 concurrencyConflicts) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable1.Update(IUpdateEntry entry) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryStore.ExecuteTransaction(IReadOnlyList1 entries, IDiagnosticsLogger1 updateLogger) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryDatabase.SaveChangesAsync(IReadOnlyList1 entries, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__79.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__77.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.DbContext.<SaveChangesAsync>d__52.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.EntityFrameworkCore.AbpDbContext.<SaveChangesAsync>d__49.MoveNext() Result Message: Abp.Domain.Uow.AbpDbConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values. ---- Abp.Domain.Uow.AbpDbConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values. -------- Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException : Conflicts were detected for instance of entity type ‘User’ on the concurrency token properties {‘ConcurrencyStamp’}. Consider using ‘DbContextOptionsBuilder.EnableSensitiveDataLogging’ to see the conflicting values.

  • Steps needed to reproduce the problem. - Upgrade from 3.5.x to 3.7.2 run UserAppService_Link_Tests unit tests

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ismcagdascommented, Jun 18, 2018

@dontboyle wrapping UserManager.CreateAsync by a unitOfWork fixes this problem. Could you try that ?

using (var uow = _unitOfWorkManager.Begin())
{
	// UserManager.CreateAsync lines here...

	await uow.CompleteAsync();
}

For UserAppService_Link_Tests, you need to modify CreateTestUsersForAccountLinkingAsync (which is in AspNet Zero) method like below ;

private async Task CreateTestUsersForAccountLinkingAsync()
{
	using (var uow = _unitOfWorkManager.Begin())
	{
		await _userManager.CreateAsync(CreateUserEntity("jnash", "John", "Nash", "jnsh2000@testdomain.com"));
		await _userManager.CreateAsync(CreateUserEntity("adams_d", "Douglas", "Adams", "adams_d@gmail.com"));
		await _userManager.CreateAsync(CreateUserEntity("artdent", "Arthur", "Dent", "ArthurDent@yahoo.com"));

		await uow.CompleteAsync();
	}
}
1reaction
dontboylecommented, Jun 22, 2018

@alirizaadiyahsi Sorry have been pulled off for a bit on a side problem, Yes @ismcagdas solution did in fact resolve the issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

IRepositoy.InsertOrUpdateAsync throwing concurrency ...
I was creating a content managment system on ABP using ... Abp.Domain.Uow.AbpDbConcurrencyException: Database operation expected to affect 1 ...
Read more >
Unit Of Work | Documentation Center | ABP.IO
ABP Framework's Unit Of Work (UOW) implementation provides an abstraction and control on a database connection and transaction scope in an application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found