Add role in ASP.NET Identity

daniel picture daniel · Oct 23, 2013 · Viewed 59.5k times · Source

How can I add a Role in the new ASP.NET Identity system (1.0)? There is a UserStore class but no RoleStore class.

I can't find any documentation on this issue.

Answer

graycrow picture graycrow · Oct 23, 2013
RoleManager = new RoleManager<IdentityRole>(
                  new RoleStore<IdentityRole>(new MyDbContext()));
var roleresult = RoleManager.Create(new IdentityRole(roleName));