title: Extending ASP.NET Identity Roles: IdentityRole is not part of the model for the current context
body: <p>I'm trying to use the new ASP.NET Identity in my MVC5 application, specifically I'm trying to integrate ASP.NET Identity into an existing database. I've already read the questions/answers on SO pertaining to DB First and ASP.NET Identity, and having followed all the recommendations I still can't add roles to my database, although I have no problems adding users. Here's my code:</p>
  
  <pre><code>var context = new PayrollDBEntities();
  var roleManager = new RoleManager&lt;AspNetRole&gt;(new RoleStore&lt;AspNetRole&gt;(context));
  
  bool roleExists = roleManager.RoleExists(roleDto.Name);
  if (roleExists){
      return false;
  }
  
  var role = new AspNetRole(roleDto.Name){
      Name = roleDto.Name,
  };
  
  IdentityResult result = roleManager.Create(role);//Getting exception here
  </code></pre>
  
  <p>At the last line of code I get an exception of type <code>'System.InvalidOperationException': The entity type IdentityRole is not part of the model for the current context.</code></p>
  
  <p>Here is my context:</p>
  
  <pre><code>public partial class PayrollDBEntities : IdentityDbContext
  {
          public PayrollDBEntities()
              : base("name=PayrollDBEntities")
          {
          }
  
          public virtual DbSet&lt;AspNetRole&gt; AspNetRoles { get; set; }
          public virtual DbSet&lt;AspNetUserClaim&gt; AspNetUserClaims { get; set; }
          public virtual DbSet&lt;AspNetUserLogin&gt; AspNetUserLogins { get; set; }
          public virtual DbSet&lt;AspNetUser&gt; AspNetUsers { get; set; }
  ......
  }
  </code></pre>
  
  <p>My <code>AspNetUser</code> and <code>AspNetRole</code> classes derive from <code>IdentityUser</code> and <code>IdentityRole</code> respectively, but I'm still getting that exception. Here is my database diagram:</p>
  
  <p><img src="https://i.stack.imgur.com/vpkWM.png" alt="enter image description here"></p>
  
  <p>Any help would be greatly appreciated.</p>