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

BilalMr
  • 307
  • 3
  • 22

1 Answers1

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);
BilalMr
  • 307
  • 3
  • 22