我试图实现基于令牌的身份验证,以修改AspNetusers表的名称并添加4个用户定义的列。因此,当我尝试注册用户时遇到以下问题
System.Data.Entity.Core.EntityCommandExecutionException:'执行命令定义时发生错误。有关详细信息,请参见内部异常。消息“无效的列名' VerificationOtp '。\ r \ n无效的列名' IsPasswordChanged ”。字符串
[Route("api/User/Register")]
[HttpPost]
public IdentityResult Register(UserModel model)
{
var userStore = new UserStore<ApplicationUser>(new ApplicationDbContext());
var manager = new UserManager<ApplicationUser>(userStore);
var user = new ApplicationUser() { Email = model.Email, UserName = model.Email };
user.FirstName = model.FirstName;
user.LastName = model.LastName;
IdentityResult result = manager.Create(user, model.Password); // This line throwing the above issue.
return result;
}
public partial class InitialDb : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.ClientUserValidations",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
FirstName = c.String(),
LastName = c.String(),
VerificationOtp = c.Int(nullable: true,defaultValue: 0),
IsPasswordChanged = c.Boolean(nullable: true,defaultValue : false),
Email = c.String(maxLength: 256),
EmailConfirmed = c.Boolean(nullable: false),
PasswordHash = c.String(),
SecurityStamp = c.String(),
PhoneNumber = c.String(),
PhoneNumberConfirmed = c.Boolean(nullable: false),
TwoFactorEnabled = c.Boolean(nullable: false),
LockoutEndDateUtc = c.DateTime(),
LockoutEnabled = c.Boolean(nullable: false),
AccessFailedCount = c.Int(nullable: false),
UserName = c.String(nullable: false, maxLength: 256),
})
.PrimaryKey(t => t.Id)
.Index(t => t.UserName, unique: true, name: "UserNameIndex");
}
public override void Down()
{
DropIndex("dbo.ClientUserValidations", "UserNameIndex");
DropTable("dbo.ClientUserValidations");
}
}