public async Task <string> Seed() { int numberOfCars = 0; if (_context.Car.Count() == 0) { Car car1 = new Car { Make = "Toyota", Model = "Corolla", Color = "Blue", Year = 2011, VIN = "123" }; Car car2 = new Car { Make = "Tesla", Model = "S", Color = "Black", Year = 2019, VIN = "456" }; Car car3 = new Car { Make = "VW", Model = "Golf", Color = "Yellow", Year = 2012, VIN = "789" }; Car car4 = new Car { Make = "Mazda", Model = "Mazda3", Color = "Purple", Year = 2010, VIN = "987" }; _context.AddRange(car1, car2, car3, car4); await _context.SaveChangesAsync(); numberOfCars = 4; } return($"{numberOfCars} Cars Added"); }
public async Task <string> Seed() { int numberOfMembers = 0; if (_context.Member.Count() == 0) { Member member1 = new Member { FirstName = "Andre", LastName = "Madar", UserName = "******", Email = "*****@*****.**" }; Member member2 = new Member { FirstName = "Teegan", LastName = "Sider", UserName = "******", Email = "*****@*****.**" }; Member member3 = new Member { FirstName = "Voldemort", LastName = "Golfinator", UserName = "******", Email = "*****@*****.**" }; Member member4 = new Member { FirstName = "Megaman", LastName = "Mazdito", UserName = "******", Email = "*****@*****.**" }; _context.AddRange(member1, member2, member3, member4); await _context.SaveChangesAsync(); numberOfMembers = 4; } return($"{numberOfMembers} Members Added"); }
public DealershipMgr() { var options = new DbContextOptionsBuilder <Lab1aContext>() .UseInMemoryDatabase(databaseName: "DealershipMgrDb").Options; _context = new Lab1aContext(options); Car car1 = new Car { Make = "Toyota", Model = "Corolla", Color = "Blue", Year = 2011, VIN = "123" }; Car car2 = new Car { Make = "Tesla", Model = "S", Color = "Black", Year = 2019, VIN = "456" }; Car car3 = new Car { Make = "VW", Model = "Golf", Color = "Yellow", Year = 2012, VIN = "789" }; Car car4 = new Car { Make = "Mazda", Model = "Mazda3", Color = "Purple", Year = 2010, VIN = "987" }; _context.AddRange(car1, car2, car3, car4); _context.SaveChangesAsync(); }