2

I am trying in my applicaton to add user outside from Registriation so outside Accountcontrol and i tried to add manually to database but it does not work also i need to take the hashpassword

1 Answer 1

4

here is the answer of my question: just create a new applicationdfcontext :)

var store = new UserStore<ApplicationUser>(new ApplicationDbContext());
    ApplicationUserManager _userManager = new ApplicationUserManager(store);
    var manger = _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
    var user = new ApplicationUser() { Email = aspNetUsers.Email, UserName = aspNetUsers.UserName };
    var usmanger= manger.Create(user, aspNetUsers.PasswordHash);
Sign up to request clarification or add additional context in comments.

Comments

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.