private void Seed() { using var context = new RentalCarsDbContext(ContextOptions); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Bookings.RemoveRange(context.Bookings); context.Cars.RemoveRange(context.Cars); context.Customers.RemoveRange(context.Customers); context.Returns.RemoveRange(context.Returns); var cars = new Car[] { new() { Id = Guid.NewGuid(), Category = CarCategory.Compact, Model = "Zaporozhets" }, new() { Id = Guid.NewGuid(), Category = CarCategory.Premium, Model = "Lamborghini Huracán" }, new() { Id = Guid.NewGuid(), Category = CarCategory.Minivan, Model = "Volvo" }, }; var customers = new Customer[] { new() { Id = Guid.NewGuid(), Email = "test", DateOfBirth = DateTime.Parse("1990-01-01") } }; context.Cars.AddRange(cars); context.Customers.AddRange(customers); context.SaveChanges(); }
private void Seed() { using var context = new RentalCarsDbContext(ContextOptions); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.SaveChanges(); }