在asp.net webform应用程序中,尝试在UPDATE-DATABASE命令之后将用户保存到AspNetUsers。以下代码不会这样做。解决方案?
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(MyApp.Models.ApplicationDbContext context)
{
if (!context.Users.Any(u => u.Email == "some@mail"))
{
var store = new UserStore<ApplicationUser>(context);
var manager = new UserManager<ApplicationUser>(store);
var user = new ApplicationUser { Email = "some@mail" };
manager.Create(user, "password");
}
}
答案 0 :(得分:1)
要添加ApplicationUser
,您必须初始化属性Username
。