I am working on the project that implements two factor authentication using SMS in C#. I am trying to use the interface called IUserEmailStore in my controller - so my controller's constructor look like this:
public AccountsController(
SignInManager<User> signInManager,
UserManager<User> userManager,
IUserStore<User> userStore,
IUserEmailStore<User> emailStore,
RepositoryContext context,
IMapper mapper,
UrlEncoder urlEncoder,
JwtHandler jwtHandler)
{
_signInManager = signInManager;
_userStore = userStore;
_userManager = userManager;
_emailStore = emailStore;
_mapper = mapper;
_urlEncoder = urlEncoder;
_jwtHandler = jwtHandler;
_context = context;
}
I am getting the following exception:
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserEmailStore`1[TwoFactorAuthenticationGoogleAuthenticatorAngular.Models.User]' while attempting to activate 'TwoFactorAuthenticationGoogleAuthenticatorAngular.Controllers.AccountsController'.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method10(Closure, IServiceProvider, Object[]) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
I included the following relevant packages - including Microsoft.Extensions.Identity.Core referred by the Microsoft documentation of the IUserEmailStore<TUser> interface.
I am running out of ideas. Can somebody help?

I have solved the problem by finding how other projects tackled it. So basically I don't DI the
IUserEmailStoreinto my controller. I DI instead aIUserStoreand I cast it toIUserEmailStore- as Microsoft returns reallyIUserEmailStore(IUserEmailStorederives fromIUserStore). That's it. Hope it helps someone.