title: Identity Provider and Unity Dependency Injection
body: <p>I have downloaded this sample in which I can try the features of Identity Provider in ASP.NET MVC 5:</p>
  
  <p><a href="http://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples">http://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples</a></p>
  
  <p>I have used many times Unity DI for my repositories, services, unit of work and other stuff without problems.</p>
  
  <p>But now, when I install Unity DI, I have many problems with the Interfaces and DI that uses  the Identity Provider.</p>
  
  <p>I just have downloaded the code of the example and I have configured  the Unity DI, but I don't want to use Unity for the Identity Membership, I want to use Unity DI just for me stuff (IRepository, IService, IUnitOfWork, etc.)</p>
  
  <p>I have this error when I try to register a user:</p>
  
  <blockquote>
    <p>The current type,
    Microsoft.AspNet.Identity.IUserStore`1[Ecoavantis.Interactive.GCI.Models.ApplicationUser],
    is an interface and cannot be constructed. Are you missing a type
    mapping?</p>
  </blockquote>
  
  <p>I read some post in which they said that I must include something like this, but I don't need to inject dependencies in Identity Provider... </p>
  
  <pre><code>container.RegisterType&lt;UserManager&lt;ApplicationUser&gt;&gt;(new HierarchicalLifetimeManager());
              container.RegisterType&lt;IUserStore&lt;ApplicationUser&gt;, UserStore&lt;ApplicationUser&gt;&gt;(new HierarchicalLifetimeManager());
  </code></pre>
  
  <p>Can anyone help me please?</p>
  
  <p><strong>Code Example:</strong></p>
  
  <pre><code> /// &lt;summary&gt;Registers the type mappings with the Unity container.&lt;/summary&gt;
          /// &lt;param name="container"&gt;The unity container to configure.&lt;/param&gt;
          /// &lt;remarks&gt;There is no need to register concrete types such as controllers or API controllers (unless you want to 
          /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.&lt;/remarks&gt;
          public static void RegisterTypes(IUnityContainer container)
          {
              // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
              // container.LoadConfiguration();
              // TODO: Register your types here
  
  
              //container.RegisterType&lt;DbContext, ApplicationDbContext&gt;(new ContainerControlledLifetimeManager());
              container.RegisterType&lt;IUnitOfWorkAsync, UnitOfWork&gt;(new PerRequestLifetimeManager());
              container.RegisterType&lt;IMainPanelService, MainPanelService&gt;();
              container.RegisterType(typeof (IRepositoryAsync&lt;&gt;), typeof (Repository&lt;&gt;));
              container.RegisterType&lt;IDataContextAsync, ecoavantisinteractivegciContext&gt;(new PerRequestLifetimeManager());
           }
  </code></pre>