Exemplo n.º 1
0
        public void ClearDb()
        {
            using (var context = new LinksContext(linksOptions))
            {
                context.CustomerLink.RemoveRange(context.CustomerLink);
                context.SaveChanges();
            };

            using (var context = new OldCustomersContext(oldCOptions))
            {
                context.OldCustomer.RemoveRange(context.OldCustomer);
                context.SaveChanges();
            };

            using (var context = new NewCustomersContext(newCOptions))
            {
                context.NewCustomer.RemoveRange(context.NewCustomer);
                context.SaveChanges();
            };
        }
Exemplo n.º 2
0
        public void SetupDb()
        {
            using (var context = new OldCustomersContext(oldCOptions))
            {
                OldCustomer customer0a = new OldCustomer()
                {
                    Id        = oldIDs[0],
                    Username  = "******",
                    FirstName = "Elon",
                    Surname   = "Musk",
                    Address   = "Los Angeles",
                };

                OldCustomer customer1a = new OldCustomer()
                {
                    Id        = oldIDs[1],
                    Username  = "******",
                    FirstName = "Jimmy",
                    Surname   = "Whales",
                    Address   = "San Francisco"
                };

                context.OldCustomer.Add(customer0a);
                context.OldCustomer.Add(customer1a);
                context.SaveChanges();
            }

            using (var context = new NewCustomersContext(newCOptions))
            {
                NewCustomer customer0b = new NewCustomer()
                {
                    Id         = newIDs[0],
                    Username   = "******",
                    GivenNames = { "Elon", "Reeve", "Musk" },
                    Email      = "*****@*****.**"
                };

                NewCustomer customer1b = new NewCustomer()
                {
                    Id         = newIDs[1],
                    Username   = "******",
                    GivenNames = { "Jimmy", "Whales" },
                    Email      = "*****@*****.**"
                };

                context.NewCustomer.Add(customer0b);
                context.NewCustomer.Add(customer1b);
                context.SaveChanges();
            }

            using (var context = new LinksContext(linksOptions))
            {
                CustomerLink customer0 = new CustomerLink()
                {
                    OldID = oldIDs[0],
                    NewID = newIDs[0]
                };

                CustomerLink customer1a = new CustomerLink()
                {
                    OldID = oldIDs[1]
                };

                CustomerLink customer1b = new CustomerLink()
                {
                    NewID = newIDs[1]
                };

                context.CustomerLink.Add(customer0);
                context.CustomerLink.Add(customer1a);
                context.CustomerLink.Add(customer1b);
                context.SaveChanges();
            }
        }