Q:

How to create the first root user using ASP.NET Identity 2?

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!

A:

1- If  your users download the source code and they will compile/deploy it in Visual studio: Put these kind of default or seed in WebConfig and read it in your class. See an example here
2- If your users normally deploy a compiled version, I have theses suggestions:

Leave it as is and inform users about the default password
Disable Auto Seed function and create a deploy webpage/controller. Make the instruction that when the users want to launch for the first time they need to goto the installer page and make the first user at that time..
Disable Auto Seed function. Create a setting table/filed in a database such as isDeployed. In the AppStart check for isDeployed and if it is false redirect all of the requests to the installer page and make the first user at that time.

