使用 Entity Framework 初始化器初始化 IdentityUser

Initialize IdentityUser using the Entity Framework initializer

由于密码是加密的,如何使用Seed方式初始化用户

您可以初始化一个 Usermanager 对象并创建用户。

protected override void Seed(ApplicationDbContext context)
{
     var userStore = new UserStore<ApplicationUser>(context);
     var userManager = new UserManager<ApplicationUser>(userStore);
     var admin = new ApplicationUser { UserName = "your username", Email = "your email" };
     userManager.Create(admin, "your password");
}