EF Core blazor Error while SaveChangesAsync()

Error: System.InvalidOperationException: A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext.

This happens if I do a custom filter/search on a RadzenDropDown field that is bound to a IQueryable list and then attempt to SaveChangesAsync(). It doesn't happen if I just pick an item from the RadzenDropDown list without filtering.

1 Like

same here.

Did you solve it?

I have the same issue here. I'm trying to save the created object from a dialog to the DB and when I try to save another one that error appears.

System.InvalidOperationException: A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext.

same here on

    public async Task<ApplicationUser> GetUserById(string id)
    {
        var user = await userManager.FindByIdAsync(id);

        if (user != null)
        {
            **user.RoleNames = await userManager.GetRolesAsync(user);**
        }
        return await Task.FromResult(user);
    }

I solved this by adding ', ServiceLifetime.Transient' to AddDbContext