title: How exactly do I use Roles in Asp.NET MVC 4?
body: <p>I've been reading tons of articles and forums but I still can't figure it out...
  I'm building an internet application using Visual Studio Express 2012 for Web, with MVC4+Razor+Entity Framework CodeFirst.</p>
  
  <p>As far as I understand, managing users and roles in MVC4 with SimpleMembership is more straightforward than it was in previous versions and should be fairly simple.</p>
  
  <p>In my application, I need to authorize only certain groups of users (e.g., only admins can access certain pages). I understand that's made by passing a parameter to the [Authorize] annotation: [Authorize(Roles="Admins")] 
  But how do I create those roles and how do I add users to them?</p>
  
  <p>In order to require authentication I added the annotation <strong>[Authorize]</strong> (with no parameters) on top of a controller method and it worked without having made any extra configurations or adding anything else. Also, when I take a look at the database that was automatically created, I see a table named webpages_UsersInRoles, with columns UserId and RoleId. All of this makes me think this has to be a pretty simple task since all seems set up and ready to be used, but I just can't figure out how ;)</p>
  
  <p>What I've tried so far (and it didn't work) was this:
  I have a "DataContextDbInitializer" class that inherits from DropCreateDatabaseIfModelChanges. The Seed method is overriden inside that class, and I added this (I had to import System.Web.Security):</p>
  
  <pre><code>Membership.CreateUser("user1", "123456");
  Roles.CreateRole("Admins");
  Roles.AddUserToRole("user1", "Admins");
  </code></pre>
  
  <p>I also inserted this tag in the  tag of the Web.config file:</p>
  
  <pre><code>&lt;roleManager
  enabled="true"
  cacheRolesInCookie="true" &gt;
  &lt;/roleManager&gt;
  </code></pre>
  
  <p>To try it out I added [Authorize(Roles="Admins")] on top of an action method in a controller, and then logged in as "admin" and tried to access that method, but no luck :(</p>
  
  <p>I don't know what else I'm missing...
  I'd be really happy if anyone could guide me through this, since it's driving me insane :P</p>
  
  <p>Thanks!</p>