How can I add roles in a empty mvc 5 project?
I searched on google but I don't found a tutorial for an empty project.
Can someone give me a link to a tutorial or help me here ?
How can I add roles in a empty mvc 5 project?
I searched on google but I don't found a tutorial for an empty project.
Can someone give me a link to a tutorial or help me here ?
This way:
var roleManager = new RoleManager<Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
if (!roleManager.RoleExists("RoleName"))
{
var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
role.Name = "RoleName";
roleManager.Create(role);
}