I'm working on an open source project using ASP.NET MVC 5 and Identity 2 and I'm wondering how to create the first(root) user in my application.
I've searched it on Google, and the only solution I found is to integrate the whole process into the Seed() function:
// From http://stackoverflow.com/questions/27498921/creating-asp-net-identity-user-in-seed-method-of-db-initializer
protected override void Seed(EvContext context)
{
//Add other entities using context methods
ApplicationUserManager manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context));
var user = new ApplicationUser { Email = "admin@myemail.com" ,UserName = "admin@myemail.com"};
var result = await manager.CreateAsync(user, "Temp_123");//this line gives error. obviously await cannot be used in non- async method and I cannot make Seed async
}
But as this is a open source project, I don't want the password to be shown on the code but be implemented somewhere while deploying. Someone tells me that I can use OWIN, but I can't find any solutions. What's your solution? Thanks!