public static async Task SeedData(SpaTemplatesContext context) { SeedUsers(context); SeedWeatherForecasts(context); await context.SaveChangesAsync(); }
private static void SeedUsers(SpaTemplatesContext context) { if (context.Users.Any()) { return; } var users = new List <ApplicationUser> { new ApplicationUser { Id = Guid.NewGuid(), AccessFailedCount = 0, Email = "*****@*****.**", EmailConfirmed = true, LockoutEnabled = false, NormalizedEmail = "*****@*****.**", NormalizedUserName = "******", TwoFactorEnabled = false, UserName = "******" }, new ApplicationUser { Id = Guid.NewGuid(), AccessFailedCount = 0, Email = "*****@*****.**", EmailConfirmed = true, LockoutEnabled = false, NormalizedEmail = "*****@*****.**", NormalizedUserName = "******", TwoFactorEnabled = false, UserName = "******" }, new ApplicationUser { Id = Guid.NewGuid(), AccessFailedCount = 0, Email = "*****@*****.**", EmailConfirmed = true, LockoutEnabled = false, NormalizedEmail = "*****@*****.**", NormalizedUserName = "******", TwoFactorEnabled = false, UserName = "******" }, }; context.AddRange(users); }
private static void SeedWeatherForecasts(SpaTemplatesContext context) { if (context.WeatherForecasts.Any()) { return; } var rng = new Random(); var weatherForecasts = Enumerable.Range(1, 10).Select(index => new WeatherForecast { Id = Guid.NewGuid(), DateFormatted = DateTime.Now.AddDays(index).ToString("d"), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }); context.AddRange(weatherForecasts); }
public Repository(SpaTemplatesContext dbContext) { DbContext = dbContext; DbSet = DbContext.Set<TEntity>(); }