-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一个上下文同时跟踪两个相同的实体 #739
Comments
你好:
|
十分感谢您的解答!!
一开始使用的是_eventBus,后来听了您的建议使用[FromServices] IEventBus eventBus,结果是一样的;
仓储实现层
仓储实现层注释的代码放开,不会报错,但是数据库没有更新Remark字段
|
Description
在更新前将实体的状态设置为Detached再更新,不报错,但是数据库没有更新。另说明还有一种情况,当结合Masa blazor时,在前端页面同时更新同一条记录也是会报同样的错误。但是单纯使用swagger测试并不会。
参考代码如下:
public async Task GetGenerateCodeAsync(AllMapTable mapTable)
{
Guid? tid = null;
//自动插入mapTable表
var table = await _mapTableRepository.FindAsync(t => t.EnTableName.Equals(mapTable));
if (table == null)
{
var description = EnumDescription.GetDescriptionAttribute(mapTable);
if (description == null)
{
throw new UserFriendlyException("获取枚举上的Description失败");
}
var command = new CreateMapTableCommand(description, mapTable.ToString());
await _eventBus.PublishAsync(command);
tid = command.Id;
}
await _codingRuleInfoRepository.GenerateCode(mapTable);
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap
1.ThrowIdentityConflict(InternalEntityEntry entry) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap
1.Add(TKey key, InternalEntityEntry entry, Boolean updateDuplicate)···.NET version
No response
MASA Framework version
No response
The text was updated successfully, but these errors were encountered: