An exception occurred while iterating over the results of a query for context type 'Cdn.Data.ApplicationDbContext'. System.InvalidOperationException: A second operation was started on this context before a previous operation completed.
<MatButton OnClick="@ApplyChanges">Apply</MatButton>
private async Task ApplyChanges()
{
IsDialogOpen = false;
if (SelectedRole != null)
{
Console.WriteLine("Begin IsInRoleAsync");
if (!await UserManager.IsInRoleAsync(CurrentUser, SelectedRole))
{
Console.WriteLine("End IsInRoleAsync");
Console.WriteLine("Begin AddToRoleAsync");
await UserManager.AddToRoleAsync(CurrentUser, SelectedRole);
Console.WriteLine("End AddToRoleAsync");
}
else
{
Console.WriteLine("End IsInRoleAsync");
}
}
if (NewUsername != null)
{
Console.WriteLine("Begin SetUserNameAsync");
await UserManager.SetUserNameAsync(CurrentUser, NewUsername);
Console.WriteLine("End SetUserNameAsync");
}
CurrentUser = null;
}
It's weird because i'm not doing any operations at the same time, and this happens when i click the button twice (with time difference) and sometimes when i do it once.