Error in program.cs
builder.Services.AddScoped<IdentityUserAccessor>();
System.AggregateException: ‘Some services are not able to be constructed (Error while validating the service descriptor ‘ServiceType: Blazorteste.Modelo.IdentityUserAccessor Lifetime: Scoped ImplementationType: Blazorteste.Modelo.IdentityUserAccessor’: Unable to resolve service for type ‘Blazorteste.Modelo.ApplicationDbContext’ while attempting to activate ‘Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore`6
using Microsoft.AspNetCore.Identity;
namespace Blazorteste.Modelo;
internal sealed class IdentityUserAccessor(UserManager<ApplicationUser> userManager, IdentityRedirectManager redirectManager)
{
public async Task<ApplicationUser> GetRequiredUserAsync(HttpContext context)
{
var user = await userManager.GetUserAsync(context.User);
if (user is null)
{
redirectManager.RedirectToWithStatus("Account/InvalidUser", $"Error: Unable to load user with ID '{userManager.GetUserId(context.User)}'.", context);
}
return user;
}
}
I have an error when creating a user to log into Blazor.