ASP.NET MVC 5 Windows Identity Foundation – Add Role
using System; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using CRMPortal.Models; public void CreateRole(String RoleName) { RoleManager<IdentityRole> rm = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext())); if (!rm.RoleExists(RoleName)) { var role = new IdentityRole(); role.Name = RoleName; rm.Create(role); } } |