0

As the password is encrypted, How can I initialize a user using the Seed method.

1 Answer 1

1

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");
}
Sign up to request clarification or add additional context in comments.

2 Comments

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 ?
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.