No users have been created during Seed method using UserManager in ASP .NET MVC applications

前端 未结 1 487
面向向阳花
面向向阳花 2020-12-19 22:03

When the Seedmethod runs, records/objects are added to my database.

Every object is added as it should till I try add users to my application(at the bo

相关标签:
1条回答
  • 2020-12-19 22:35

    You have to get the current manager from the context:

    var manager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
    

    Be sure to inlude the namespace for this:

    using Microsoft.AspNet.Identity.Owin;
    

    Using this manager instance, you should be able to create a user correctly.

    0 讨论(0)
提交回复
热议问题