score:0

Accepted answer
 public class ExistingInitializer : ClearDatabaseSchemaIfModelChanges
    {
        protected override void Seed(ExistingContext context)
        {
            List orders = new List
            {
                new Order { OrderId = 10, Item = "Guitars", Quantity = 2, Id = Guid.NewGuid().ToString()},
                new Order { OrderId = 20, Item = "Drums", Quantity = 10, Id = Guid.NewGuid().ToString()},
                new Order { OrderId = 30, Item = "Tambourines", Quantity = 20, Id = Guid.NewGuid().ToString() }
            };

            List customers = new List
            {
                new Customer { CustomerId = 1, Name = "John", Orders = new Collection {
                    orders[0]}, Id = Guid.NewGuid().ToString()},
                new Customer { CustomerId = 2, Name = "Paul", Orders = new Collection {
                    orders[1]}, Id = Guid.NewGuid().ToString()},
                new Customer { CustomerId = 3, Name = "Ringo", Orders = new Collection {
                    orders[2]}, Id = Guid.NewGuid().ToString()},
            };

            foreach (Customer c in customers)
            {
                context.Customers.Add(c);
            }

            base.Seed(context);
        }
    }


Related Query

More Query from same tag