I have created a method in my Startup.cs file that has the following method in it:
private void createRolesandUsers()
ApplicationDbContext context = new ApplicationDbContext();
var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
// creating first Boss Role and creating a default Boss User
// first we create Admin rool
var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
role.Name = "Boss";
//add a note to get this to rerun?
//Here we create a Admin super user who will maintain the website
var user = new ApplicationUser();
user.UserName = "Boss";
user.Email = "firstname.lastname@example.org";
string userPWD = "Pa$$w0rd";
var chkUser = UserManager.Create(user, userPWD);
//Add default User to Role Admin
var result1 = UserManager.AddToRole(user.Id, "Boss");
I then call this method from Configuration. It works great to create the user and the role of Boss. I can confirm the user has been created and also the role when I remotely log into my Azure app's SQL database. Unfortunately, I am unable to log into the account, I have double checked the user name and password and copied and pasted both into the email input and password input. Does any one know what could be wrong with my code to cause this and any suggestions to fix it?
Thank you for your help with this in advance!