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