title: Adding custom role to user ASP.NET Identity
body: <p><strong>Context of problem</strong></p>
  
  <p>In my web application I've been using ASP.NET Identity. I've created custom user profiles by inheriting the User class from IdentityUser. To be able to connect the Roles with for example rolegroups I've also created a custom role class within my database which inherits from the IdentityRole class.</p>
  
  <p><em>My database model looks like this:</em> <img src="https://i.stack.imgur.com/O7NYq.png" alt="Part of databasemodel"></p>
  
  <p>The problem isn't in creating a user. <em>This just works:</em></p>
  
  <pre><code>var userManager = new UserManager&lt;User&gt;(new UserStore&lt;User&gt;(_context));
  var result = userManager.Create(user, password);
  </code></pre>
  
  <p>Same with creating a role.</p>
  
  <pre><code>var rm = new RoleManager&lt;Role&gt;(new RoleStore&lt;Role&gt;(_context));
  var result = rm.Create(new Role(name));
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>But its when I try to attach a role to a user (<em>With the following code</em>)</p>
  
  <pre><code>var um = new UserManager&lt;User&gt;(new UserStore&lt;User&gt;(_context));
  var result = um.AddToRole(userId, roleName);
  </code></pre>
  
  <p>The error I get is basically "<strong>The entity type IdentityRole is not part of the model for the current context.</strong>"</p>
  
  <p>Which is true, btw. But how can I make it that my Role entity is seen as the IdentityRole entity, which it basically is, or has to be.</p>
  
  <p>See the full stacktrace here: <a href="http://pastebin.com/sEPv5LiT" rel="nofollow noreferrer">http://pastebin.com/sEPv5LiT</a></p>
  
  <p>Thanks in advance!</p>