【发布时间】:2015-12-01 01:00:32
【问题描述】:
如何在空的 mvc 5 项目中添加角色?
我在 google 上搜索,但没有找到 empty 项目的教程。
谁能给我一个教程链接或在这里帮助我?
【问题讨论】:
标签: asp.net-mvc-5 roles asp.net-mvc-5.1 asp.net-roles
如何在空的 mvc 5 项目中添加角色?
我在 google 上搜索,但没有找到 empty 项目的教程。
谁能给我一个教程链接或在这里帮助我?
【问题讨论】:
标签: asp.net-mvc-5 roles asp.net-mvc-5.1 asp.net-roles
这边:
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);
}
【讨论】: