asp.net-mvc – 为什么UserManager.CreateIdentityAsync()正在寻找Identi
发布时间:2020-05-25 04:44:22 所属栏目:asp.Net 来源:互联网
导读:我正在使用Identity2.0和MVC5 CodeFirst我已经扩展了IdentityUser和IdentityRole,如下所示: public class ApplicationUser : IdentityUser{ [Required] [StringLength(50)] public string FirstName { get; set; }
|
我正在使用Identity2.0和MVC5 CodeFirst我已经扩展了IdentityUser和IdentityRole,如下所示: public class ApplicationUser : IdentityUser
{
[Required]
[StringLength(50)]
public string FirstName { get; set; }
[Required]
[StringLength(50)]
public string LastName { get; set; }
}
public class ApplicationRole : IdentityRole
{
[Required]
[StringLength(50)]
public string ProperName { get; set; }
[Required]
public string Description { get; set; }
}
public class MyAppDb : IdentityDbContext<ApplicationUser,ApplicationRole,string,IdentityUserLogin,IdentityUserRole,IdentityUserClaim>
{
public MyAppDb()
: base("MyAppDb")
{
}
}
注意MyAppDb继承自IdentityDbContext但我传递的是ApplicationRole而不是IdentityRole.我的ApplicationRole继承自IdentityRole,所以这应该不是问题. 但… 我的AccountController抛出了这个错误: The entity type IdentityRole is not part of the model for the current context. 在此代码中的UserManager.CreateIdentityAsync(…): private async Task SignInAsync(ApplicationUser user,bool isPersistent)
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = await UserManager.CreateIdentityAsync(user,DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent },identity);
}
用户正在这里创建: var user = await UserManager.FindAsync(model.UserName,model.Password);
if (user != null)
{
await SignInAsync(user,model.RememberMe);
return RedirectToLocal(returnUrl);
}
什么是“重大故障”? (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 基于MVC的API – 如何实现OAuth?
- asp.net-mvc – MvcHtmlString.Create()和Html.Raw()之间的
- asp.net-mvc – Asp.Net MVC Ajax.BeginForm没有通过Ajax提
- asp.net – JQGrid不显示数据
- asp.net – Response.End()和Response.Flush()之间的差异
- asp.net – 将涵盖.NET中的TDD,DDD和设计模式的图书
- ASP.Net – 在负载平衡环境中处理会话数据?
- asp.net-mvc – Windows 8 VS2012 IISExpress Windows身份验
- asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
- asp.net-mvc – 我在MVC 5 Visual Studio 2013中的“创建强
推荐文章
站长推荐
热点阅读
