I am trying to register, my users, using CQRS.
I am registering MediatR:
services.AddMediatR(typeof(MyCommand).GetTypeInfo().Assembly);
public class Handler : IRequestHandler<RegisterCommand, object>
{
private readonly MyDbContext _context;
private readonly IMediator _mediator;
private readonly UserManager<User> _userManager;
public Handler(IYawaMVPDbContext context, IMediator mediator, UserManager<User> userManager)
{
_context = context;
_mediator = mediator;
_userManager = userManager;
}
}
I am getting the following exceptions:
InvalidOperationException: Unable to resolve service for type 'MyDbContext' while attempting to activate 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore
6[MyCore.Domain.Entities.User,MyCore.MyApp.Persistence.MyDbContext,System.String,Microsoft.AspNetCore.Identity.IdentityUserClaim
1[System.String],Microsoft.AspNetCore.Identity.IdentityUserLogin1[System.String],Microsoft.AspNetCore.Identity.IdentityUserToken
1[System.String]]'. Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, bool throwIfCallSiteNotFound)InvalidOperationException: Error constructing handler for request of type MediatR.IRequestHandler`2[MyCore.MyApp.Application.Users.Commands.Register.RegisterCommand,System.Object].
Register your handlers with the container. See the samples in GitHub for examples.
Any help appreciated.