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.BackgroundJobs.BackgroundJobManager - Database operation expected to affect 1 row(s) but actually affected 0 row(s).

See original GitHub issue

Abp.BackgroundJobs.BackgroundJobManager - Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. Abp.Domain.Uow.AbpDbConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. —> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagationAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(Tuple2 parameters, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IReadOnlyList1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) — End of inner exception stack trace — at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.SaveChangesAsync(CancellationToken cancellationToken) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContextAsync(DbContext dbContext) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesAsync() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.CompleteUowAsync() at Abp.Domain.Uow.UnitOfWorkBase.CompleteAsync() at Abp.Domain.Uow.UnitOfWorkInterceptor.<>c__DisplayClass6_0.<<PerformAsyncUow>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Abp.Threading.InternalAsyncHelper.AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func1 postAction, Action1 finalAction) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func1 action) at Abp.BackgroundJobs.BackgroundJobManager.TryProcessJob(BackgroundJobInfo jobInfo)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ddo88commented, Jan 26, 2019

I have the same problem with this code

	[UnitOfWork]
	public void HandleEvent(EntityCreatedEventData<ProcessComment> eventData)
	{
			AsyncHelper.RunSync(() =>
				BackgroundJobManager.EnqueueAsync<ArkNotificationJob, ArkNotificationJobArgs>(
					new ArkNotificationJobArgs
					{
						ProcessId = eventData.Entity.Id,
						Identifier = eventData.Entity.Identifier,
						CreatorUserId = eventData.Entity.CreatorId,
						TenantId = eventData.Entity.TenantId,
					})
			);
	}
	public class ArkNotificationJob : BackgroundJob<ArkNotificationJobArgs>, ITransientDependency {
		private readonly INotificationPublisher _notificationPublisher;
		public ArkNotificationJob(INotificationPublisher NotificationPublisher)
		{
			_notificationPublisher = NotificationPublisher;
		}

		[UnitOfWork]
		public override void Execute(ArkJobArgs args)
		{
			var body = new CustomNotification()
			{
				ProcessId = args.ProcessId,
				Identifier = args.Identifier
			};
			AsyncHelper.RunSync(() => _notificationPublisher.PublishAsync(ArkCustomNotifications.NewProcess, body, null, NotificationSeverity.Info, new Abp.UserIdentifier[] { new Abp.UserIdentifier(eventData.Entity.TenantId, eventData.Entity.CreatorUserId) }));
		}
	}

help please, what i´m doing wrong

0reactions
malimingcommented, Jan 28, 2019

@ddo88 Can you use abp’s Startup Templates to reproduce the problem? If you can, please share the template project code.

https://aspnetboilerplate.com/Templates

Read more comments on GitHub >

github_iconTop Results From Across the Web

database operation expected to affect 1 row(s) but actually ...
Unable to edit db entries using EFCore, EntityState.Modified: "Database operation expected to affect 1 row(s) but actually affected 0 row(s)." ...
Read more >
The database operation was expected to affect 1 row(s), but ...
The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities ......
Read more >
Background job is not re-executed #8894
I have issue with Background job tries. Job are created in AbpBackgroundJobs table and executed once. After job failed, job record in the ......
Read more >
'database operation expected to affect 1 row(s) but actually ...
When I ran my code, it got to the part where it tries to save the entity. But returns the following error: Microsoft.EntityFrameworkCore....
Read more >
EF Core: Database operation expected to affect 1 row(s) but ...
The full-blown title of the error was "Database operation expected to affect 1 row(s) but actually affected 0 row(s).
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