title: adding roles in asp.net mvc 4 application using identity provider
body: <p>I have a ASP.NET MVC 4 Web Application "APP1" which has Entity Framework implemented using the DB First approach. I'm using the automatically generated <code>Account</code>-<code>model</code>, -<code>views</code> and -<code>controller</code> for Authentication.</p>
  
  <p>So far, everything seems fine. I can add new users and log in.
  My question now is: <strong>How can I add roles to my users?</strong> I basically only need 1 role.</p>
  
  <p><strong><em>Additional Information</em></strong></p>
  
  <p><em>I made 2 small modifications:</em></p>
  
  <ul>
  <li><em>I extended the AccountModel with an additional EmailAdress property</em></li>
  <li><em>I changed the ConnectionString Property so my EF SQL Server Instance is being used instead of a LocalDb</em></li>
  </ul>
  
  <p><em>The following tables were automatically generated at my EF SQL Server DB</em></p>
  
  <ul>
  <li><em>dbo.UserProfile</em></li>
  <li><em>dbo.webpages_Membership</em></li>
  <li><em>dbo.webpages_OAuthMembership</em></li>
  <li><em>dbo.webpages_Roles</em></li>
  <li><em>dbo.webpages_UsersInRoles</em></li>
  </ul>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I ended up with creating them manually. See my TSQL Code bellow</p>
  
  <pre><code>INSERT INTO webpages_Roles (RoleName) VALUES ('canEdit')
  INSERT INTO webpages_UsersInRoles (UserId, RoleId) VALUES (2, 1)
  </code></pre>
  
  <p>To make an <code>ActionResult</code> available only for authorized persons with a specific role, I decorated them as follow:</p>
  
  <pre><code>[Authorize(Roles = "canEdit")]
  public ActionResult Index()
  {
      // return View();
  }
  </code></pre>