private void SeedData() { _vehicleDbContext.RemoveRange(_vehicleDbContext.Cars); _vehicleDbContext.AddRange( new Car { Make = "nissan", Model = "x-trail", Engine = "2-cylinder", Doors = 4, Wheels = 4, VehicleType = VehicleType.Car, BodyType = BodyType.SUV }, new Car { Make = "nissan", Model = "x-trail Ti", Engine = "4-cylinder", Doors = 4, Wheels = 4, VehicleType = VehicleType.Car, BodyType = BodyType.SUV } ); _vehicleDbContext.SaveChanges(); }
public static void Seed(VehicleDbContext context) { if (!context.Vehicles.Any()) { context.AddRange ( new Vehicle { VehicleId = "YS2R4X20005399401", RegistrationNo = "ABC123", CustomerID = 1, CustomerName = "Kalles Grustransporter AB", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "VLUR4X20009093588", RegistrationNo = "DEF456", CustomerID = 1, CustomerName = "Kalles Grustransporter AB", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "VLUR4X20009048066", RegistrationNo = "GHI789", CustomerID = 1, CustomerName = "Kalles Grustransporter AB", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "YS2R4X20005388011", RegistrationNo = "JKL012", CustomerID = 2, CustomerName = "johans-bulk-ab", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "YS2R4X20005387949", RegistrationNo = "MNO345", CustomerID = 2, CustomerName = "johans-bulk-ab", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "VLUR4X20009048066", RegistrationNo = "PQR678", CustomerID = 3, CustomerName = "haralds-värdetransporter-ab", LastPingTime = DateTime.Now }, new Vehicle { VehicleId = "YS2R4X20005387055", RegistrationNo = "STU901", CustomerID = 3, CustomerName = "haralds-värdetransporter-ab", LastPingTime = DateTime.Now } ); var output = context.SaveChanges(); var output1 = output; } }