有没有人有这个问题.他抛出了我的错误:名称不能为null或为空.但是在表中没有名为"Name"的属性.我想自定义Asp.Net Identity.
调节器
public class HomeController : Controller { // // GET: /Home/ public async TaskIndex() { var userStore = new UserStore (new Identity_2Context()); var manager = new UserManager (userStore); var user = new User() { UserName = "TehnoMac",Email = "TehnoMac@tehcno.com",IsApproved = true,IsLockedOut = false, CreatedDate = DateTime.Now,LastActivityDate = DateTime.Now,LastLoginDate = DateTime.Now,FailedPasswordAnswerAttemptCount = 0, FailedPasswordAttemptCount = 0 }; var result = await manager.CreateAsync(user, "test123test"); if (result.Succeeded) { var authenticationManager = HttpContext.GetOwinContext().Authentication; var userIdentity = manager.Create(user, DefaultAuthenticationTypes.ApplicationCookie); } else { ViewBag.Text = result.Errors.FirstOrDefault(); } return View(); } }
IdentityModel公共类ApplicationUser:IdentityUser {}
public class MyClaim:IdentityUserClaim{ } public class MyRole:IdentityRole { } public class MyUserRole:IdentityUserRole { } public class MyUserLogin:IdentityUserLogin { } public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext() : base("DefaultConnection") { } }
jao.. 9
确保您已指定用户名.我得到了同样的错误,在设置UserName
属性后,错误就消失了.