title: The current types, IUserStore<ApplicationUser> and DbConnection, are respectively an interface and abstract class and cannot be constructed
body: <p>If I surf to <code>http://localhost:58472/Account/Register</code> I've this exception </p>
  
  <blockquote>
    <p><strong><code>System.InvalidOperationException:</code></strong> The current type, <code>IUserStore&lt;ApplicationUser&gt;</code>, is an interface and cannot be constructed. Are you missing a type mapping?</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>public class ApplicationUserManager : UserManager&lt;ApplicationUser&gt;
  {
      public ApplicationUserManager(IUserStore&lt;ApplicationUser&gt; store)
          : base(store)
      { }
  
      public static ApplicationUserManager Create(
          IdentityFactoryOptions&lt;ApplicationUserManager&gt; options, 
          IOwinContext context) 
      {
          var manager = new ApplicationUserManager(
              new UserStore&lt;ApplicationUser&gt;(context.Get&lt;ApplicationDbContext&gt;())
          );
  
          // other code
          return manager;   
      }
  }
  </code></pre>
  
  <p>and here is the code into the controller:</p>
  
  <pre><code>[Authorize]
  public class AccountController : Controller
  {
      private ApplicationSignInManager _signInManager;
      private ApplicationUserManager _userManager;
  
      public AccountController()
      {
      }
  
      public AccountController(
          ApplicationUserManager userManager,
          ApplicationSignInManager signInManager)
      {
          UserManager = userManager;
          SignInManager = signInManager;
      }
  
      public ApplicationSignInManager SignInManager
      {
          get
          {
              return _signInManager ?? 
                  HttpContext.GetOwinContext().Get&lt;ApplicationSignInManager&gt;();
          }
          private set
          {
              _signInManager = value;
          }
      }
  
      public ApplicationUserManager UserManager
      {
          get
          {
              return _userManager ?? 
                  HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
          }
          private set
          {
              _userManager = value;
          }
      }
  
      [HttpGet]
      [AllowAnonymous]
      public ActionResult Login(string returnUrl)
      {
          ViewBag.ReturnUrl = returnUrl;
          return View();
      }
  }
  </code></pre>
  
  <p>So you can see if you read my code, I've nothing changed to the original code when you create a new MVC project, but I've got the error above. What did I wrong? </p>
  
  <p>I've well made a new controller named <code>ProfileController</code> with the same code as in my second code block but without the <code>ApplicationSignInManager</code> because I don't need that.</p>
  
  <p>I also use an Unity container to register and manage the services. Here is the code:</p>
  
  <pre><code>public static class UnityConfig
  {
      public static void RegisterComponents()
      {
          var container = new UnityContainer();
  
          container.RegisterType&lt;IGenericRepo&lt;Category&gt;, GenericRepo&lt;Category&gt;&gt;();
          container.RegisterType&lt;ICategoryService, CategoryService&gt;();
          //container.RegisterType&lt;IUser, ApplicationUser&gt;(); 
  
          DependencyResolver.SetResolver(new UnityDependencyResolver(container));
      }
  }
  </code></pre>
  
  <p>If I uncomment the line in code above, there aren't any difference when I run the site.</p>
  
  <hr>
  
  <p><strong>Update:</strong> </p>
  
  <p>By a comment by @Jay I've added this code in the Unity manager.</p>
  
  <pre><code>container.RegisterType&lt;IUserStore&lt;ApplicationUser&gt;, UserStore&lt;ApplicationUser&gt;&gt;();
  </code></pre>
  
  <p>Now I've got this exception:</p>
  
  <blockquote>
    <p><strong><code>System.InvalidOperationException</code>:</strong> The current type, <code>System.Data.Common.DbConnection</code>, is an abstract class and cannot be constructed. Are you missing a type mapping?</p>
  </blockquote>
  
  <p>Here is some information from the stack trace:</p>
  
  <ol>
  <li><p><code>InvalidOperationException</code></p>
  
  <blockquote>
    <p>An error occurred when trying to create a controller of type <code>AccountController</code>. Make sure that the controller has a parameterless public constructor.</p>
  </blockquote>
  
  <p>Yes, I've got a paramaterless public constructor.</p></li>
  <li><p><code>ResolutionFailedException</code></p>
  
  <blockquote>
    <p>Resolution of the dependency failed, type = <code>"AccountController"</code>, name = <code>"(none)"</code>.</p>
  </blockquote></li>
  </ol>
  
  <p>So I've added this line in the Unity manager:</p>
  
  <pre><code>container.RegisterType&lt;IDbConnection, DbConnection&gt;();
  </code></pre>
  
  <p>But I've still have the same exception.</p>
  
  <blockquote>
    <p>The current type, <code>System.Data.Common.DbConnection</code>...</p>
  </blockquote>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>By a comment by @RandyLevy I've tried this, helping by this question <a href="https://stackoverflow.com/questions/21927785/configure-unity-di-for-asp-net-identity">Configure Unity DI for ASP.NET Identity</a>:</p>
  
  <ol>
  <li><p>Adding this to the <code>AccountController</code>:</p>
  
  <pre><code>// two fields added
  private readonly UserManager&lt;ApplicationUser&gt; _userManager;
  private readonly RoleManager&lt;IdentityRole&gt; _roleManager;
  
  // constructor added
  public AccountController(
      IUserStore&lt;ApplicationUser&gt; userStore, 
      IRoleStore&lt;IdentityRole&gt; roleStore, 
      ApplicationSignInManager signInManager)
  {
      _userManager = new UserManager&lt;ApplicationUser&gt;(userStore);
      _roleManager = new RoleManager&lt;IdentityRole&gt;(roleStore);
      SignInManager = signInManager; // I need this
  }
  
  public ApplicationSignInManager SignInManager // I need this
  {
      get
      {
          return _signInManager ?? 
              HttpContext.GetOwinContext().Get&lt;ApplicationSignInManager&gt;();
      }
      private set
      {
          _signInManager = value;
      }
  }
  
  public UserManager&lt;ApplicationUser&gt; UserManager // replace by other property 
                                                  // type of ApplicationUserManager 
  {
      get
      {
          return _userManager ?? 
              HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
      }
      //private set // comment this because _usermanager is readonly.
      //{
      //    _userManager = value;
      //}
  }
  
  //public ApplicationUserManager UserManager // replaced by the property type of 
  //                                          // UserManager&lt;ApplicationUser&gt;
  //{
  //    get
  //    {
  //        return _userManager ?? 
  //            HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
  //    }
  //    private set
  //    {
  //        _userManager = value;
  //    }
  //}
  </code></pre></li>
  <li><p>Adding this into UnityManager:</p>
  
  <pre><code>InjectionConstructor accountInjectionConstructor = 
      new InjectionConstructor(new ApplicationDbContext());
  
  container.RegisterType&lt;AccountController&gt;();
  container.RegisterType&lt;IController, Controller&gt;();
  
  container.RegisterType
      &lt;IRoleStore&lt;IdentityRole&gt;, RoleStore&lt;IdentityRole&gt;&gt;
      (accountInjectionConstructor); // on this line
  
  container.RegisterType
      &lt;IUserStore&lt;ApplicationUser&gt;, UserStore&lt;ApplicationUser&gt;&gt;
      (accountInjectionConstructor);
  </code></pre></li>
  </ol>
  
  <p>But I've got this error (no run time exception) on the line with the comment:</p>
  
  <blockquote>
    <p>The type <code>RoleStore&lt;IdentityRole&gt;</code> cannot be used as type parameter <code>TTo</code> in the generic type or method below:</p>
  
  <pre><code>UnityContainerExtensions.RegisterType&lt;TFrom, TTo&gt;
      (IUnityContainer, params InjectionMember[])
  </code></pre>
    
    <p>There is no implicit reference conversion from <code>RoleStore&lt;IdentityRole&gt;</code> to <code>IRoleStore&lt;IdentityRole&gt;</code>.</p>
  </blockquote>