admin管理员组文章数量:1565366
I'm trying to insert records in two tables, but getting the exception. Could you please help me to resolve the issue.
First I tried the below code.
await _testRepository.InsertAsync(test);
await _xyzRepository.InsertAsync(xyz);
Then I tried this code, But nothing is working for me.
try
{
var test = new Test();
using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
{
int? tenantId = _unitOfWorkManager.Current.GetTenantId();
using (_unitOfWorkManager.Current.SetTenantId(tenantId))
{
await _testRepository.InsertAsync(test);
var xyz = new XYZ();
await _xyzRepository.InsertAsync(xyz);
await _unitOfWorkManager.Current.SaveChangesAsync();
await uow.CompleteAsync();
}
}
}
catch (Exception ex)
{
throw new UserFriendlyException(ex.Message);
}
Exception
Message:
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/fwlink/?LinkId=527962 for
information on understanding and handling optimistic concurrency
exceptions.
stack trace:
at
Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32
commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected) at
Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch
版权声明:本文标题:mysql 删除记录预计,数据库操作预计会影响1行,但实际上会影响0行 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1726603792a1077329.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论