.net core Aspnet核心标识角色更新错误

.net core Aspnet核心标识角色更新错误,.net-core,asp.net-identity,.net Core,Asp.net Identity,我正在尝试更新存在角色,但出现错误 代码 专用只读角色管理器\u角色管理器; 公共编辑模型(RoleManager RoleManager) { _roleManager=roleManager; } [BindProperty] 公共IdentityRole IdentityRole{get;set;} 公共异步任务OnGetAsync(字符串id) { if(id==null) { 返回NotFound(); } IdentityRole=wait_rolemager.FindByIdAsy

我正在尝试更新存在角色,但出现错误

代码

专用只读角色管理器\u角色管理器;
公共编辑模型(RoleManager RoleManager)
{
_roleManager=roleManager;
}
[BindProperty]
公共IdentityRole IdentityRole{get;set;}
公共异步任务OnGetAsync(字符串id)
{
if(id==null)
{
返回NotFound();
}
IdentityRole=wait_rolemager.FindByIdAsync(id);
if(IdentityRole==null)
{
返回NotFound();
}
返回页();
}
公共异步任务OnPostAsync()
{
如果(!ModelState.IsValid)
{
返回页();
}
尝试
{
wait _rolemager.updateSync(IdentityRole);//此处发生错误。
}
catch(DbUpdateConcurrencyException)
{
}
返回页首(“/索引”);
}
错误

InvalidOperationException:无法跟踪实体类型“IdentityRole”的实例,因为已在跟踪另一个具有{'Id'}相同键值的实例。附着现有实体时,请确保仅附着一个具有给定键值的实体实例。考虑使用“dBraveTopStudioBuff.EnabelSythViDeAtGracg”来查看冲突的键值。 Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap.Add(TKey,InternalEntityEntry)


我更改了这样的代码和它的工作,但这是一个奇怪的,当我更改名称时,会更改automatic IdentityRole规范化名称列

 var role = await _roleManager.FindByIdAsync(IdentityRole.Id);
            role.Name = IdentityRole.Name;
            await _roleManager.UpdateAsync(role);
我在那里找到的