I\'ve this setup with code first model:
public class TestContext :IdentityDbContext
{
public TestContext()
: base(\"TestConnectio
I have solved with this:
Create a custom UserManager
public class ApplicationUserManager : UserManager
{
public ApplicationUserManager(IUserStore store, IOptions optionsAccessor, IPasswordHasher passwordHasher, IEnumerable> userValidators, IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger> logger, IHttpContextAccessor contextAccessor) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger, contextAccessor) { }
public override Task FindByIdAsync(string userId)
{
return Users.Include(c => c.Esercizio).FirstOrDefaultAsync(u => u.Id == userId);
}
}
Replace default UserManager service
In your ConfigureServices add this:
services.AddIdentity().AddEntityFrameworkStores().AddDefaultTokenProviders().AddUserManager();
Change arguments for DI
from
[FromServices]UserManager userManager
to
[FromServices]ApplicationUserManager userManager
I hope this helps