private void SeedUsers(SportStoreDbContext context) { var adminUser = new User { Email = "*****@*****.**", NormalizedEmail = "*****@*****.**", UserName = "******", Role = "test" }; adminUser.PasswordHash = _passwordHash.HashPassword(adminUser, "Qwerty@123"); context.Users.Add(adminUser); }
public void Initialize(SportStoreDbContext context) { if (!context.Database.EnsureCreated()) { return; } var contextName = typeof(SportStoreDbContext).Name; try { _logger.LogInformation($"Migrating database associated with context {contextName}"); SeedUsers(context); context.SaveChanges(); _logger.LogInformation($"Migrated database associated with context {contextName}"); } catch (Exception ex) { _logger.LogError(ex, $"An error occurred while migrating the database used on context {contextName}"); } }