I am encountering an issue while using the ExecuteUpdateAsync
feature of Entity Framework Core v8.0.0 in an ASP.NET Core 8 Web API project.
The error message I receive is as follows:
This SqlTransaction has completed; it is no longer usable
at Microsoft.Data.SqlClient.SqlTransaction.ZombieCheck()
at Microsoft.Data.SqlClient.SqlTransaction.Commit()
at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Commit()
Here are the code details :
private async Task DemoUpdateTestTable(DemoReq demoReq, IEnumerable<string>? toUpdateMailList, CancellationToken cancellationToken)
{
await _demoDbContext.TestTable
.Where(recordsToUpdate => toUpdateMailList.Contains(recordsToUpdate.EmailAddress) &&
recordsToUpdate.Id == demoReq.Id)
.ExecuteUpdateAsync(setters => setters
.SetProperty(r => r.ModifyUserId, demoReq.CreateUserId)
.SetProperty(r => r.ModifyDate, demoReq.ModifyDate)
.SetProperty(r => r.IsApproved, r => r.IsApproved != true ? null : (bool?)null),
cancellationToken);
}
Can anyone help me here with some code sample which will serve as a reference for my implementation?
4