public static void Initialize(BattleshipDBContext context, BattleshipContext userContext) { context.Database.Migrate(); userContext.Database.Migrate(); // add register users in UsersRolesDB addUsers(userContext); // add roles in UserRolesDB addUserInventory(context); // add random names to the HighScore addUserHighScore(context); }
/// <summary> /// This method task is to initalize data for the User table of the /// Identity model /// </summary> /// <param name="context"></param> private static void addUsers(BattleshipContext context) { if (context.Users.Any()) { var delete = from u in context.Users select u; foreach (IdentityUser use in delete) { context.Users.Remove(use); } context.SaveChanges(); } // JohnDoe password is Tom1996! for testing var users = new IdentityUser[] { new IdentityUser { Id = "54b09006-6d89-422d-bd89-a902f309acbe", UserName = "******", NormalizedUserName = "******", Email = "*****@*****.**", NormalizedEmail = "*****@*****.**", EmailConfirmed = true, PasswordHash = "AQAAAAEAACcQAAAAEE+cuefISYzXCw85lprijJVHu/13nHLOXBPncGdlcbfMhlcZ3vzwG/ixvxK0Wk59xg==", SecurityStamp = "GSS2ESOSS2AFFOZVJXBDBNT3QN7YLBL6", ConcurrencyStamp = "020bf919-cff4-442b-9e67-ff5a65766cbd" } }; foreach (IdentityUser iu in users) { context.Users.Add(iu); } context.SaveChanges(); }