我正在尝试在我的MVC5应用程序中使用新的ASP.NETIdentity,特别是我正在尝试将ASP.NETIdentity集成到现有数据库中。我已经阅读了有关DBFirst和ASP.NETIdentity的SO问题/答案,并且遵循了所有建议我仍然无法向我的数据库添加角色,尽管我在添加用户时没有问题。这是我的代码:varcontext=newPayrollDBEntities();varroleManager=newRoleManager(newRoleStore(context));boolroleExists=roleManager.RoleExists(roleDto.Name);
我正在尝试完成对.NETCore2.0的更新,但弹出了几个错误:问题:我有两个类,ApplicationRole和ApplicationUser,它们继承了IdentityRole和IdentityUser的一些属性。随着Core2.0的更新,我收到以下错误,声称找不到IdentityRole和IdentityUser。但是,包Microsoft.AspNetCore.Identity.EntityFrameworkCore2.0安装在新版本的.NETCore中关于IdentityRole:消息1:Thetypeornamespacename'IdentityRole'couldnot
如何在mvc5中找到登录用户的角色?我用这段代码造就了用户privateboolAddUserAndRole(){IdentityResultir;varrm=newRoleManager(newRoleStore(newApplicationDbContext()));ir=rm.Create(newIdentityRole("admin"));varuser=newApplicationUser(){UserName="Admin"};varresult=UserManager.Create(user,"somepassword");UserManager.AddToRole(us