As the password is encrypted, How can I initialize a user using the Seed method.
1 Answer
You can initialize a Usermanager object and create user.
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");
}
2 Comments
Zerghouni Idriss
It doesn't resolve the problem. Because the password you provide is encrypted. And when I want to login with the provided. It's not recognized thanks. Any Idea ?
tmg
It works for me. The password that you set on create method is the password not the hash. what is the error you are getting when you try to login?