title: HttpContext.GetOwinContext().GetUserManager<AppRoleManager>() return null
body: <p>I've used ASP.NET Identity 2 for creating role but the result of <code>HttpContext.GetOwinContext().GetUserManager&lt;AppRoleManager&gt;()</code> was null.</p>
  
  <p>Then I couldn't create the role.</p>
  
  <p>How can I solve this problem?</p>
  
  <pre><code>public class MVCController : Controller
  {
      public MVCController()
      {
  
      }
      public AppRoleManager RoleManager // returns null ?!
      {
          get
          {
              return HttpContext.GetOwinContext().GetUserManager&lt;AppRoleManager&gt;();
          }
      }
      public User CurrentUser
      {
          get
          {
              string currentUserId = User.Identity.GetUserId();
              User currentUser = DataContextFactory.GetDataContext().Users.FirstOrDefault(x =&gt; x.Id.ToString() == currentUserId);
              return currentUser;
          }
      }
      public IAuthenticationManager AuthManager
      {
          get
          {
  
              return HttpContext.GetOwinContext().Authentication;
          }
      }
      public AppUserManager UserManager
      {
          get
          {
              return HttpContext.GetOwinContext().GetUserManager&lt;AppUserManager&gt;();
          }
      }
  } 
  </code></pre>
  
  <p><strong><em>My Controller:</em></strong></p>
  
  <pre><code>public class RoleAdminController : MVCController
  {
      [HttpPost]
      public async Task&lt;ActionResult&gt; CreateRole([Required]string name)
      {
          if (ModelState.IsValid)
          {
              if (RoleManager != null) // RoleManager is null, why?!
              {
                  IdentityResult result = await RoleManager.CreateAsync(new Role { Name = name });
                  if (result.Succeeded)
                  {
                      return RedirectToAction("Index");
                  }
                  else
                  {
                      AddErrorsFromResult(result);
                  }
              }
          }
          return View(name);
      }
  }
  </code></pre>
  
  <p><strong><em>AppRoleManager:</em></strong></p>
  
  <pre><code>public class AppRoleManager : RoleManager&lt;Role, int&gt;, IDisposable
  {
      public AppRoleManager(RoleStore&lt;Role, int, UserRole&gt; store)
          : base(store)
      {
      }
      public static AppRoleManager Create(IdentityFactoryOptions&lt;AppRoleManager&gt; options, IOwinContext context)
      {
          return new AppRoleManager(new RoleStore&lt;Role, int, UserRole&gt;(DataContextFactory.GetDataContext()));
      }
  }
  </code></pre>