Neo*_*o42 6 asp.net-mvc entity-framework azure
我试图按照本教程,但我陷入了尝试添加基于ApplicationUser的代码的区域.角色部分.
我确实包括这些行:
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
Run Code Online (Sandbox Code Playgroud)
我的编译错误
Error 1 The type or namespace name 'ApplicationUser' could not be found (are you missing a using directive or an assembly reference?) c:\users\blah\documents\visual studio 2013\Projects\blah\blah\Migrations\Configuration.cs 96 38 blah
编辑:这是整个代码片段:
bool AddUserAndRole(ContactManager.Models.ApplicationDbContext context)
{
IdentityResult ir;
var rm = new RoleManager<IdentityRole>
(new RoleStore<IdentityRole>(context));
ir = rm.Create(new IdentityRole("canEdit"));
var um = new UserManager<ApplicationUser>(
new UserStore<ApplicationUser>(context));
var user = new ApplicationUser()
{
UserName = "user1",
};
ir = um.Create(user, "Passw0rd1");
if (ir.Succeeded == false)
return ir.Succeeded;
ir = um.AddToRole(user.Id, "canEdit");
return ir.Succeeded;
}
Run Code Online (Sandbox Code Playgroud)
Hor*_*Net 11
您是否创建了继承自IdentityUser的ApplicationUser类?如果是这样,您是否将ApplicationUser类所在的命名空间添加到Configuration类?
这是解决此错误最合理的事情.
| 归档时间: |
|
| 查看次数: |
11858 次 |
| 最近记录: |