public static ShippingContext Create() { var db = new ShippingContext(); db.Database.EnsureCreated(); return(db); }
public static void CreateSeedData() { using (var db = new ShippingContext()) { var options = Initial.ShippingOptions(); foreach (var productShippingOptions in ShippingContext.Initial.ProductShippingOptions()) { var optionsForThisProduct = options.Where(o => o.ProductShippingOptionsId == productShippingOptions.Id); productShippingOptions.Options.AddRange(optionsForThisProduct); db.ProductShippingOptions.Add(productShippingOptions); } db.SaveChanges(); } }