title: Why am I getting an IdentityRole error?
body: <p>Using Identity 2.0 After registering a user, the user is created in the database, there is code in the Account controller to create an identity and sign the user in.  This is when I get the error.  Here is the code producing the error:</p>
  
  <pre><code>var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
  </code></pre>
  
  <p>And here is the error:</p>
  
  <blockquote>
    <p>The entity type IdentityRole is not part of the model for the current
    context.</p>
  </blockquote>
  
  <p>My Model looks like this:</p>
  
  <pre><code>namespace MyApp.Models
  {
      public class ApplicationUser : IdentityUser
      {
          [Required]
          [StringLength(50)]
          public string FirstName { get; set; }
  
          [Required]
          [StringLength(50)]
          public string LastName { get; set; }
      }
  
      public class ApplicationRole : IdentityRole
      {
          [Required]
          [StringLength(50)]
          public string ProperName { get; set; }
  
          [Required]
          public string Description { get; set; }
      }
  
  
      public class MyAppDb : IdentityDbContext&lt;ApplicationUser, ApplicationRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim&gt;
      {
          public MyAppDb()
              : base("MyAppDb")
          {
          }
      }
  }
  </code></pre>
  
  <p>My <code>UserManager</code> is created like this in the Account controller:</p>
  
  <pre><code>namespace MyApp.Controllers
  {
      [Authorize]
      public class AccountController : BaseController
      {
          private UserManager&lt;ApplicationUser&gt; _userManager;
  
          public AccountController()
          {
          }
  
          public AccountController(UserManager&lt;ApplicationUser&gt; userManager)
          {
              UserManager = userManager;
          }
  
          public UserManager&lt;ApplicationUser&gt; UserManager
          {
              get
              {
                  return _userManager = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(new MyAppDb()));
              }
              private set
              {
                  _userManager = value;
              }
          }
  
          ...
      }
  }
  </code></pre>