コード例 #1
0
        public void Initialize(CustomerApiContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            // Look for any Products
            if (context.Customers.Any())
            {
                return;   // DB has been seeded
            }

            List <SharedCustomers> customers = new List <SharedCustomers>
            {
                new SharedCustomers {
                    Name = "Customer0", Email = "*****@*****.**", BillingAddress = "Wuhan's first street", Phone = 666, CreditStanding = 15, ShippingAddress = "Corona Street"
                },
                new SharedCustomers {
                    Name = "Customer1", Email = "*****@*****.**", BillingAddress = "Somalia's latest street", Phone = 0101, CreditStanding = 2395123, ShippingAddress = "Mogadiscio"
                },
                new SharedCustomers {
                    Name = "Customer2", Email = "*****@*****.**", BillingAddress = "EASV", Phone = 1453, CreditStanding = 0, ShippingAddress = "SDU"
                },
                new SharedCustomers {
                    Name = "Samuel Adams", Email = "*****@*****.**", BillingAddress = "Malaga", Phone = 6969, CreditStanding = 1, ShippingAddress = "SomewhereInSpain"
                },
                new SharedCustomers {
                    Name = "New Guy", Email = "awesome@guy.", BillingAddress = "moon", Phone = 24123, CreditStanding = 2, ShippingAddress = "yes"
                }
            };

            context.Customers.AddRange(customers);
            context.SaveChanges();
        }
コード例 #2
0
        // This method will create and seed the database.
        public void Initialize(CustomerApiContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            // Look for any Products
            if (context.Customers.Any())
            {
                return;   // DB has been seeded
            }

            List <Customer> customers = new List <Customer>
            {
                new Customer {
                }
            };

            context.Customers.AddRange(customers);
            context.SaveChanges();
        }
コード例 #3
0
 public CustomerRepository(CustomerApiContext context)
 {
     db = context;
 }