internal static void CreateSeedData(string databaseName = null) { if (!string.IsNullOrWhiteSpace(databaseName)) { _databaseName = databaseName; } 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(); }
internal static void DropDatabase() { using var db = new ShippingContext(); db.Database.EnsureDeleted(); }