public void SeedInitial(EntityContext context) { if (!context.Addresses.Any()) { var addresses = new List <Address>() { new Address(cep: "17052520"), new Address(cep: "44573100"), new Address(cep: "50080490") }; context.AddRange(addresses); context.SaveChanges(); } if (!context.Customers.Any()) { var addresses = context.Addresses.ToList(); var customers = new List <Customer>() { new Customer(addressId: addresses.First(x => x.CEP == "17052520").Id, name: "Zier Zuveiku"), new Customer(addressId: addresses.First(x => x.CEP == "44573100").Id, name: "Vikehel Pleamakh"), new Customer(addressId: addresses.First(x => x.CEP == "50080490").Id, name: "Diuor PleaBolosmakh") }; context.AddRange(customers); context.SaveChanges(); } }
public void SeedInitial() { if (!_context.Addresses.Any()) { var addresses = new List <Address>() { new Address().AddCep("17052520"), new Address().AddCep("44573100"), new Address().AddCep("50080490") }; _context.AddRange(addresses); _context.SaveChanges(); } if (!_context.Customers.Any()) { var addresses = _context.Addresses.ToList(); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "17052520").Id, name: "Zier Zuveiku")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "44573100").Id, name: "Vikehel Pleamakh")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "50080490").Id, name: "Diuor PleaBolosmakh")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "44573100").Id, name: "Fulano")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "50080490").Id, name: "Fulano Beltrano")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "17052520").Id, name: "Diuor PleaBolosmakh")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "44573100").Id, name: "Luiz Costa Alves")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "50080490").Id, name: "Diuor PleaBolosmakh")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "44573100").Id, name: "Diuor PleaBolosmakh")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "17052520").Id, name: "Harold P. Long")); _context.Add(new Customer(addressId: addresses.First(x => x.CEP == "50080490").Id, name: "Diuor PleaBolosmakh")); int i = _context.SaveChanges(); } }