public static void Seed(SalesDbContext context) { Product firstProduct = new Product() { Name = "Shampoo", Price = 5.2M, Quantity = 3 }; StoreLocation firstStoreLocation = new StoreLocation() { LocationName = "bul. Dragan Cankov 54, Sofia" }; Customer firstCustomer = new Customer() { Name = "Stefcho", Email = "*****@*****.**", CreditCardNumber = "901192837842283742", }; Sale firstSale = new Sale() { Product = firstProduct, Customer = firstCustomer, StoreLocation = firstStoreLocation, Date = new DateTime(2017, 10, 14) }; Product secondProduct = new Product() { Name = "Parfume", Price = 150.99M, Quantity = 17 }; StoreLocation secondStoreLocation = new StoreLocation() { LocationName = "NYC, 123 Central Park" }; Customer secondCustomer = new Customer() { Name = "David", Email = "*****@*****.**", CreditCardNumber = "901192883740293742", }; Sale secondSale = new Sale() { Product = secondProduct, Customer = secondCustomer, StoreLocation = secondStoreLocation, Date = new DateTime(2017, 09, 13) }; Product thirdProduct = new Product() { Name = "Cleaning kid", Price = 15.99M, Quantity = 7 }; StoreLocation thirdStoreLocation = new StoreLocation() { LocationName = "NYC, 93 Central Park" }; Customer thirdCustomer = new Customer() { Name = "Steve", Email = "*****@*****.**", CreditCardNumber = "901192888443293731", }; Sale thirdSale = new Sale() { Product = thirdProduct, Customer = thirdCustomer, StoreLocation = thirdStoreLocation, Date = new DateTime(2016, 09, 13) }; Product fourthProduct = new Product() { Name = "Tires", Price = 559.99M, Quantity = 4 }; StoreLocation fourthStoreLocation = new StoreLocation() { LocationName = "ul. Angel Kynchev, Sofia" }; Customer fourthCustomer = new Customer() { Name = "Pesho", Email = "*****@*****.**", CreditCardNumber = "901192888938475109", }; Sale fourthSale = new Sale() { Product = fourthProduct, Customer = fourthCustomer, StoreLocation = fourthStoreLocation, Date = new DateTime(2016, 09, 13) }; Product fifthProduct = new Product() { Name = "House", Price = 333333999.99M, Quantity = 1 }; StoreLocation fifthStoreLocation = new StoreLocation() { LocationName = "bul. Andrei Lqpchev 82, Sofia" }; Customer fifthCustomer = new Customer() { Name = "Ivan", Email = "*****@*****.**", CreditCardNumber = "901192888938273645", }; Sale fifthSale = new Sale() { Product = fifthProduct, Customer = fifthCustomer, StoreLocation = fifthStoreLocation }; context.Sales.AddRange(new[] { firstSale, secondSale, thirdSale, fourthSale, fifthSale }); }
protected override void Seed(SalesContext context) { Customer customer1 = new Customer() { CreditCardNumber = "1234567", Email = "*****@*****.**", FirstName = "User", LastName = "Userov" }; Customer customer2 = new Customer() { CreditCardNumber = "0123456", Email = "*****@*****.**", FirstName = "User2", LastName = "Userov2" }; Customer customer3 = new Customer() { CreditCardNumber = "11111", Email = "*****@*****.**", FirstName = "User3", LastName = "Userov3" }; Customer customer4 = new Customer() { CreditCardNumber = "4444", Email = "*****@*****.**", FirstName = "User4", LastName = "Userov4" }; Customer customer5 = new Customer() { CreditCardNumber = "5555", Email = "*****@*****.**", FirstName = "User5", LastName = "Userov5" }; context.Customers.Add(customer1); context.Customers.Add(customer2); context.Customers.Add(customer3); context.Customers.Add(customer4); context.Customers.Add(customer5); Product product1 = new Product() { Name = "Milk", Price = 10.00m, Quantity = 1 }; Product product2 = new Product() { Name = "Eggs", Price = 12.00m, Quantity = 12 }; Product product3 = new Product() { Name = "Salt", Price = 110.00m, Quantity = 1 }; Product product4 = new Product() { Name = "Ice", Price = 0.09m, Quantity = 11232 }; Product product5 = new Product() { Name = "Sugar", Price = 9.99m, Quantity = 1 }; context.Products.Add(product1); context.Products.Add(product2); context.Products.Add(product3); context.Products.Add(product4); context.Products.Add(product5); StoreLocation location1 = new StoreLocation() { LocationName = "Billa" }; StoreLocation location2 = new StoreLocation() { LocationName = "Kaufland" }; StoreLocation location3 = new StoreLocation() { LocationName = "FantastiKo" }; StoreLocation location4 = new StoreLocation() { LocationName = "Lidle" }; StoreLocation location5 = new StoreLocation() { LocationName = "Lelq Gosho" }; context.StoreLocations.Add(location1); context.StoreLocations.Add(location2); context.StoreLocations.Add(location3); context.StoreLocations.Add(location4); context.StoreLocations.Add(location5); Sale sale1 = new Sale() { Customer = customer1, Date = new DateTime(2017, 03, 03), Product = product1, StoreLocation = location1 }; Sale sale2 = new Sale() { Customer = customer1, Date = new DateTime(2017, 03, 03), Product = product2, StoreLocation = location1 }; Sale sale3 = new Sale() { Customer = customer2, Date = new DateTime(2016, 03, 03), Product = product1, StoreLocation = location2 }; Sale sale4 = new Sale() { Customer = customer2, Date = new DateTime(2016, 03, 03), Product = product2, StoreLocation = location2 }; Sale sale5 = new Sale() { Customer = customer1, Date = new DateTime(2016, 03, 03), Product = product3, StoreLocation = location1 }; context.Sales.Add(sale1); context.Sales.Add(sale2); context.Sales.Add(sale3); context.Sales.Add(sale4); context.Sales.Add(sale5); context.SaveChanges(); base.Seed(context); }