public static void DbInitialize(MasterDBContext context) { context.Database.EnsureCreated(); // Look for any Entrys. if (context.Articles.Any()) { return; // DB has been seeded } // Article Types var articleTypes = new ArticleType[] { new ArticleType { Name = "Assembly" }, new ArticleType { Name = "Material" }, new ArticleType { Name = "Consumable" } }; foreach (ArticleType at in articleTypes) { context.ArticleTypes.Add(at); } context.SaveChanges(); // Units var units = new Unit[] { new Unit { Name = "Kilo" }, new Unit { Name = "Litre" }, new Unit { Name = "Pieces" } }; foreach (Unit u in units) { context.Units.Add(u); } context.SaveChanges(); var machines = new Machine[] { new Machine { Capacity = 1, Name = "Säge", Count = 1, MachineGroup = new MachineGroup { Name = "Zuschnitt" } }, new Machine { Capacity = 1, Name = "Bohrer", Count = 1, MachineGroup = new MachineGroup { Name = "Bohrwerk" } }, new Machine { Capacity = 1, Name = "MontagePlatform", Count = 1, MachineGroup = new MachineGroup { Name = "Montage" } }, new Machine { Capacity = 1, Name = "MontagePlatform2", Count = 1, } }; machines.Last().MachineGroup = machines.Single(n => n.Name == "MontagePlatform").MachineGroup; foreach (var m in machines) { context.Machines.Add(m); } context.SaveChanges(); var machineTools = new MachineTool[] { new MachineTool { MachineId = machines.Single(m => m.Name == "Säge").Id, SetupTime = 1, Name = "Sägeblatt 1mm Zahnabstant" }, new MachineTool { MachineId = machines.Single(m => m.Name == "Bohrer").Id, SetupTime = 1, Name = "M6 Bohrkopf" }, }; foreach (var mt in machineTools) { context.MachineTools.Add(mt); } context.SaveChanges(); // Articles var articles = new Article[] { new Article { Name = "Kipper", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00 }, new Article { Name = "Rahmengestell", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00 }, new Article { Name = "Ladebehälter", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00 }, new Article { Name = "Chassis", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00 }, new Article { Name = "Rad", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.00 }, new Article { Name = "Felge", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 2, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.00 }, new Article { Name = "Bodenplatte", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 4.00 }, new Article { Name = "Aufliegeplatte", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 3.00 }, new Article { Name = "Seitenwand land", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.50 }, new Article { Name = "Seitenwand kurz", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 2.00 }, new Article { Name = "Bodenplatte Behälter", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 4.00 }, new Article { Name = "Fahrerhaus", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5.00 }, new Article { Name = "Motorblock", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 3.00 }, new Article { Name = "Achse", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.50 }, new Article { Name = "Knopf", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.05 }, new Article { Name = "Kippgelenk", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1 }, new Article { Name = "Holz 1,5m x 3,0m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5 }, new Article { Name = "Unterlegscheibe", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.05 }, new Article { Name = "Leim", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 5.00 }, new Article { Name = "Dübel", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 3, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 3.00 }, new Article { Name = "Verpackung", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 7.00 }, new Article { Name = "Bedienungsanleitung", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.50 }, }; foreach (Article a in articles) { context.Articles.Add(a); } context.SaveChanges(); // get the name -> id mappings var DBArticles = context .Articles .ToDictionary(p => p.Name, p => p.Id); // create Stock Entrys for each Article foreach (var article in DBArticles) { var Stocks = new Stock[] { new Stock { ArticleForeignKey = article.Value, Name = "Stock: " + article.Key, Min = (article.Key == "Kipper") ? 1 : 0, Max = 50, Current = (article.Key == "Kipper") ? 1 : 0 } }; foreach (Stock s in Stocks) { context.Stocks.Add(s); } context.SaveChanges(); } var workSchedule = new WorkSchedule[] { new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Kipper").Id, Name = "Kipper Hochzeit", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "MontagePlatform").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Kipper").Id, Name = "Kipper Ladefläche Kleben", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "MontagePlatform").MachineGroupId, HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Rahmengestell").Id, Name = "Rahmen zuschneiden", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "Säge").MachineGroupId , HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Rahmengestell").Id, Name = "Löcher für Achse in den Rahmen bohren", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "Bohrer").MachineGroupId , HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Bodenplatte").Id, Name = "Bodenplatte zuschneiden", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "Säge").MachineGroupId , HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Rahmengestell").Id, Name = "Achse mit Rahmen Verschrauben", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "MontagePlatform").MachineGroupId, HierarchyNumber = 30 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Rad").Id, Name = "Felge auf Rad Aufziehen", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "MontagePlatform").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Rad").Id, Name = "Rad mit Achse verschrauben", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "MontagePlatform").MachineGroupId, HierarchyNumber = 20 }, }; foreach (var ws in workSchedule) { context.WorkSchedules.Add(ws); } context.SaveChanges(); var articleBom = new List <ArticleBom> { new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Kipper").Id, Name = "Kipper" }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Rahmengestell").Id, Name = "Rahmengestell", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Kipper").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Chassis").Id, Name = "Chassis", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Kipper").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Ladebehälter").Id, Name = "Ladebehälter", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Kipper").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Bodenplatte").Id, Name = "Bodenplatte", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Rahmengestell").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Achse").Id, Name = "Achse", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Rahmengestell").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Rad").Id, Name = "Rad", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Rahmengestell").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Felge").Id, Name = "Felge", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Rad").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Dübel").Id, Name = "Dübel", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Rad").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Holz 1,5m x 3,0m").Id, Name = "Holz 1,5m x 3,0m", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Bodenplatte").Id }, }; foreach (var item in articleBom) { context.ArticleBoms.Add(item); } context.SaveChanges(); //create Businesspartner var businessPartner = new BusinessPartner() { Debitor = true, Kreditor = false, Name = "Toys'R'us Spielwarenabteilung" }; var businessPartner2 = new BusinessPartner() { Debitor = false, Kreditor = true, Name = "Material Großhandel" }; context.BusinessPartners.Add(businessPartner); context.BusinessPartners.Add(businessPartner2); context.SaveChanges(); var artToBusinessPartner = new ArticleToBusinessPartner[] { new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Dübel").Id, PackSize = 100, Price = 0.10, DueTime = 2 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Chassis").Id, PackSize = 1, Price = 2, DueTime = 2 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Ladebehälter").Id, PackSize = 1, Price = 3, DueTime = 2 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Achse").Id, PackSize = 10, Price = 0.50, DueTime = 2 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Holz 1,5m x 3,0m").Id, PackSize = 1, Price = 1, DueTime = 2 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Felge").Id, PackSize = 10, Price = 0.20, DueTime = 2 }, }; foreach (var art in artToBusinessPartner) { context.ArticleToBusinessPartners.Add(art); } context.SaveChanges(); //create order var orders = new List <Order>() { new Order { BusinessPartnerId = businessPartner.Id, DueTime = 40, Name = "Erste Kipperbestellung" }, new Order { BusinessPartnerId = businessPartner.Id, DueTime = 70, Name = "Zweite Kipperbestellung" }, new Order { BusinessPartnerId = businessPartner.Id, DueTime = 100, Name = "Dritte Kipperbestellung" } }; foreach (var order in orders) { context.Orders.Add(order); } context.SaveChanges(); //create orderParts var orderParts = new List <OrderPart>() { new OrderPart() { Quantity = 7, ArticleId = articles.Single(a => a.Name == "Kipper").Id, OrderId = 1, IsPlanned = false }, new OrderPart() { Quantity = 4, ArticleId = articles.Single(a => a.Name == "Kipper").Id, OrderId = 2, IsPlanned = false }, new OrderPart() { Quantity = 1, ArticleId = articles.Single(a => a.Name == "Kipper").Id, OrderId = 3, IsPlanned = false }, }; foreach (var orderPart in orderParts) { context.OrderParts.Add(orderPart); } context.SaveChanges(); }
public static void DbInitialize(MasterDBContext context) { context.Database.EnsureCreated(); // Look for any Entrys. if (context.Articles.Any()) { return; // DB has been seeded } // Article Types var articleTypes = new ArticleType[] { new ArticleType { Name = "Assembly" }, new ArticleType { Name = "Material" }, new ArticleType { Name = "Consumable" } }; context.ArticleTypes.AddRange(articleTypes); context.SaveChanges(); // Units var units = new Unit[] { new Unit { Name = "Kilo" }, new Unit { Name = "Litre" }, new Unit { Name = "Pieces" } }; context.Units.AddRange(units); context.SaveChanges(); var cutting = new MachineGroup { Name = "Cutting", Stage = 1, ImageUrl = "/images/Production/saw.svg" }; var drills = new MachineGroup { Name = "Drills", Stage = 2, ImageUrl = "/images/Production/drill.svg" }; var assemblyUnit = new MachineGroup { Name = "AssemblyUnits", Stage = 3, ImageUrl = "/images/Production/assemblys.svg" }; var machines = new Machine[] { new Machine { Capacity = 1, Name = "Saw 1", Count = 1, MachineGroup = cutting }, new Machine { Capacity = 1, Name = "Saw 2", Count = 1, MachineGroup = cutting }, new Machine { Capacity = 1, Name = "Drill 1", Count = 1, MachineGroup = drills }, new Machine { Capacity = 1, Name = "AssemblyUnit 1", Count = 1, MachineGroup = assemblyUnit }, new Machine { Capacity = 1, Name = "AssemblyUnit 2", Count = 1, MachineGroup = assemblyUnit } }; context.Machines.AddRange(machines); context.SaveChanges(); var machineTools = new MachineTool[] { new MachineTool { MachineId = machines.Single(m => m.Name == "Saw 1").Id, SetupTime = 1, Name = "Saw blade" }, new MachineTool { MachineId = machines.Single(m => m.Name == "Drill 1").Id, SetupTime = 1, Name = "M6 head" }, }; context.MachineTools.AddRange(machineTools); context.SaveChanges(); // Articles var articles = new Article[] { // Final Product new Article { Name = "Dump-Truck", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/05_Truck_final.jpg" }, new Article { Name = "Race-Truck", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/06_Race-Truck_final.jpg" }, new Article { Name = "Skeleton", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/01_Bodenplatte.jpg" }, new Article { Name = "Truck-Bed", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/03_Ladefläche.jpg" }, new Article { Name = "Chassis Type: Dump", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/02_Gehäuse.jpg" }, new Article { Name = "Chassis Type: Race", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 20.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/08_Race-Truck_Chassie.jpg" }, new Article { Name = "Race Wing", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/07_Race-Wing.jpg" }, // Chassies new Article { Name = "Cabin", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.75, ToPurchase = false, ToBuild = true }, new Article { Name = "Engine-Block", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 3.00, ToPurchase = false, ToBuild = true }, // Truck Bed new Article { Name = "Side wall long", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.35, ToPurchase = false, ToBuild = true }, new Article { Name = "Side wall short", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.25, ToPurchase = false, ToBuild = true }, new Article { Name = "Base plate Truck-Bed", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.40, ToPurchase = false, ToBuild = true }, new Article { Name = "Dump Joint" /*Kippgelenk*/, ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.90, ToPurchase = true, ToBuild = false }, // Engine Extension and Race Wing new Article { Name = "Engine Race Extension", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.50, ToPurchase = false, ToBuild = true }, // Skeleton new Article { Name = "Wheel", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.00, ToPurchase = true, ToBuild = false }, new Article { Name = "Base plate", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.80, ToPurchase = false, ToBuild = true }, new Article { Name = "Semitrailer" /*Aufleger*/, ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.10, ToPurchase = true, ToBuild = false }, new Article { Name = "Washer", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.02, ToPurchase = true, ToBuild = false }, // base Materials new Article { Name = "Timber Plate 1,5m x 3,0m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.20, ToPurchase = true, ToBuild = false }, new Article { Name = "Timber Block 0,20m x 0,20m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.70, ToPurchase = true, ToBuild = false }, new Article { Name = "Glue", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Litre").Id, Price = 0.01, ToPurchase = true, ToBuild = false }, new Article { Name = "Pegs", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 3, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.01, ToPurchase = true, ToBuild = false }, new Article { Name = "Pole", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.25, ToPurchase = true, ToBuild = false }, new Article { Name = "Button", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.05, ToPurchase = true, ToBuild = false }, new Article { Name = "Packing", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 2.15, ToPurchase = true, ToBuild = false }, new Article { Name = "User Manual", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.50, ToPurchase = true, ToBuild = false }, }; context.Articles.AddRange(articles); context.SaveChanges(); // create Stock Entrys for each Article foreach (var article in articles) { var stock = new Stock { ArticleForeignKey = article.Id, Name = "Stock: " + article.Name, Min = (article.ToPurchase) ? 1000 : 0, Max = (article.ToPurchase) ? 2000 : 0, Current = (article.ToPurchase) ? 1000 : 0, StartValue = (article.ToPurchase) ? 1000 : 0, }; context.Stocks.Add(stock); context.SaveChanges(); } var workSchedule = new WorkSchedule[] { // assemble Truck new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Wedding", Duration = 15, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Glue Truck-Bed", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, // assemble Truck new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Wedding", Duration = 15, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Glue Race Wing", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, // assemble chassie new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Assemble Lamps", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Mount Engine to Cabin", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, // assemble chassie new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Assemble Lamps", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Mount Engine Extension", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Mount Engine to Cabin", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 30 }, // assemble Skeleton new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "mount poles with wheels to Skeleton", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Screw wheels onto poles", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Glue Semitrailer", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 30 }, // assemble Truck Bed new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Glue side walls and base plate together", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Mount hatchback", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20 }, // assemble Race Wing new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Cut shape", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Drill Mount Holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, // Engine Race Extension new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Cut shape", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Drill Mount Holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, // side Walls for Truck-bed new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Cut long side", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Cut short side", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Cut Base plate Truck-Bed", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, // engin Block new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Cut Engine-Block", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, // cabin new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cut Cabin", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Cabin").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, // Base Plate new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Base plate").Id, Name = "Cut Base plate", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Base plate").Id, Name = "drill holes for axis mount", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20 }, }; context.WorkSchedules.AddRange(workSchedule); context.SaveChanges(); var articleBom = new List <ArticleBom> { // Final Products new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Dump-Truck" }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Race-Truck" }, // Bom For DumpTruck new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Skeleton", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "User Manual").Id, Name = "User Manual", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Chassis Type: Dump", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Truck-Bed", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Packing").Id, Name = "Packing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id }, // Bom For Race Truck new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Skeleton", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "User Manual").Id, Name = "User Manual", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Chassis Type: Race", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Race Wing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Packing").Id, Name = "Packing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id }, // Bom for Skeleton new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Base plate").Id, Name = "Base plate", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Wheel").Id, Name = "Wheel", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Semitrailer").Id, Name = "Semitrailer", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Washer").Id, Name = "Washer", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id }, // Bom For Chassis Dump new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cabin", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Engine-Block", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id }, // Bom For Chassis Race new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cabin", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Engine-Block", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Engine Race Extension", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id }, // Bom for Truck-Bed new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Side wall long", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Side wall short", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Base plate Truck-Bed", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Dump Joint").Id, Name = "Dump Joint", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 10, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id }, // Bom for some Assemblies new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Side wall long").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Side wall short").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Base plate").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race Wing").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Cabin").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Engine-Block").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Engine Race Extension").Id }, }; context.ArticleBoms.AddRange(articleBom); context.SaveChanges(); //create Businesspartner var businessPartner = new BusinessPartner() { Debitor = true, Kreditor = false, Name = "Toys'R'us toy department" }; var businessPartner2 = new BusinessPartner() { Debitor = false, Kreditor = true, Name = "Material wholesale" }; context.BusinessPartners.Add(businessPartner); context.BusinessPartners.Add(businessPartner2); context.SaveChanges(); var artToBusinessPartner = new ArticleToBusinessPartner[] { new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Skeleton").Id, PackSize = 10, Price = 20.00, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Truck-Bed").Id, PackSize = 10, Price = 20.00, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Chassis Type: Dump").Id, PackSize = 10, Price = 20.00, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Chassis Type: Race").Id, PackSize = 10, Price = 25.00, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Cabin").Id, PackSize = 10, Price = 1.75, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Engine-Block").Id, PackSize = 10, Price = 0.40, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Engine Race Extension").Id, PackSize = 10, Price = 1.00, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Side wall long").Id, PackSize = 10, Price = 0.55, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Side wall short").Id, PackSize = 10, Price = 0.45, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Base plate Truck-Bed").Id, PackSize = 10, Price = 0.40, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Dump Joint").Id /*Kippgelenk*/, PackSize = 50, Price = 0.90, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Wheel").Id, PackSize = 150, Price = 0.35, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Base plate").Id, PackSize = 10, Price = 0.80, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Semitrailer" /*Aufleger*/).Id, PackSize = 25, Price = 0.10, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Race Wing").Id, PackSize = 10, Price = 1.50, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Washer").Id, PackSize = 150, Price = 0.02, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Timber Plate 1,5m x 3,0m").Id, PackSize = 100, Price = 0.20, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Timber Block 0,20m x 0,20m").Id, PackSize = 100, Price = 0.20, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Glue").Id, PackSize = 1000, Price = 0.01, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Pegs").Id, PackSize = 200, Price = 0.01, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Pole").Id, PackSize = 200, Price = 0.25, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Button").Id, PackSize = 500, Price = 0.05, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Packing").Id, PackSize = 50, Price = 2.50, DueTime = 15 }, new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "User Manual").Id, PackSize = 50, Price = 0.20, DueTime = 15 }, }; context.ArticleToBusinessPartners.AddRange(artToBusinessPartner); context.SaveChanges(); var simConfigs = new List <SimulationConfiguration>(); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 1 Name = "Lot 5, 24h, 24h, 0.2", Lotsize = 5, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 2 Name = "Lot 10, 24h, 24h, 0.2", Lotsize = 10, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 3 Name = "Lot 1, 8h, 8h, 0.2", Lotsize = 1, MaxCalculationTime = 480, OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 480, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 4 Name = "Lot 1, 28h, 24h, 0.2", Lotsize = 1, MaxCalculationTime = 1680, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 5 Name = "Lot 1, 24h, 24h, 0", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.0 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 6 Name = "Lot 1, 24h, 24h, 0.2", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 7 Name = "Lot 1, 24h, 24h, 0.4", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.4 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 8 Name = "decentral dev 0", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.0 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 9 Name = "decentral dev 0.2", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.2 }); simConfigs.Add(new SimulationConfiguration() { //simconfigId = 10 Name = "decentral dev 0.4", Lotsize = 1, MaxCalculationTime = 1440, // test // 10080, // 7 days OrderQuantity = 600, Seed = 1340, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 20160, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 480, SettlingStart = 2880, WorkTimeDeviation = 0.4 }); context.SimulationConfigurations.AddRange(simConfigs); context.SaveChanges(); }
public static void DbInitialize(MasterDBContext context) { context.Database.EnsureCreated(); // Look for any Entrys. if (context.Articles.Any()) { return; // DB has been seeded } // Article Types var articleTypes = new ArticleType[] { new ArticleType { Name = "Assembly" }, new ArticleType { Name = "Material" }, new ArticleType { Name = "Consumable" } }; context.ArticleTypes.AddRange(articleTypes); context.SaveChanges(); // Units var units = new Unit[] { new Unit { Name = "Kilo" }, new Unit { Name = "Litre" }, new Unit { Name = "Pieces" } }; context.Units.AddRange(units); context.SaveChanges(); var machines = new Machine[] { //new Machine{Capacity=1, Name="Säge", Count = 1, MachineGroup = new MachineGroup{ Name = "Zuschnitt" } }, //new Machine{Capacity=1, Name="Bohrer", Count = 1, MachineGroup = new MachineGroup{ Name = "Bohrwerk" } }, new Machine { Capacity = 1, Name = "Montage 1", Count = 1, MachineGroup = new MachineGroup { Name = "Montage" } }, new Machine { Capacity = 1, Name = "Montage 2", Count = 1, MachineGroup = new MachineGroup { Name = "Montage" } } }; context.Machines.AddRange(machines); context.SaveChanges(); var machineTools = new MachineTool[] { new MachineTool { MachineId = machines.Single(m => m.Name == "Montage 1").Id, SetupTime = 1, Name = "Sägeblatt 1mm Zahnabstant" }, new MachineTool { MachineId = machines.Single(m => m.Name == "Montage 1").Id, SetupTime = 1, Name = "M6 Bohrkopf" }, }; context.MachineTools.AddRange(machineTools); context.SaveChanges(); // Articles var articles = new Article[] { new Article { Name = "Tisch", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00, ToBuild = true, ToPurchase = false }, new Article { Name = "Tisch-Platte", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 10.00, ToBuild = true, ToPurchase = false }, new Article { Name = "Tisch-Bein", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5.00, ToBuild = true, ToPurchase = false }, new Article { Name = "Holz 1,5m x 3,0m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5, ToBuild = false, ToPurchase = true }, new Article { Name = "Schrauben", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 3, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.05, ToBuild = false, ToPurchase = true }, }; context.Articles.AddRange(articles); context.SaveChanges(); // get the name -> id mappings var DBArticles = context .Articles .ToDictionary(p => p.Name, p => p.Id); // create Stock Entrys for each Article foreach (var article in DBArticles) { var stocks = new Stock[] { new Stock { ArticleForeignKey = article.Value, Name = "Stock: " + article.Key, Min = (article.Key == "Schrauben")? 50 : 0, Max = 100, Current = (article.Key == "Schrauben")? 100 : 0 } }; context.Stocks.AddRange(stocks); context.SaveChanges(); } var articleBom = new List <ArticleBom> { // Tisch new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Tisch").Id, Name = "Tisch" }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Tisch-Platte").Id, Name = "Tisch-Platte", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Tisch").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Tisch-Bein").Id, Name = "Tisch-Bein", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Tisch").Id }, new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Schrauben").Id, Name = "Schrauben", Quantity = 8, ArticleParentId = articles.Single(a => a.Name == "Tisch").Id }, // Tisch-Platte new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Holz 1,5m x 3,0m").Id, Name = "Holz 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Tisch-Platte").Id }, // Tisch-Bein new ArticleBom { ArticleChildId = articles.Single(a => a.Name == "Holz 1,5m x 3,0m").Id, Name = "Holz 1,5m x 3,0m", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Tisch-Bein").Id }, }; context.ArticleBoms.AddRange(articleBom); context.SaveChanges(); var workSchedule = new WorkSchedule[] { // Tisch new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Tisch").Id, Name = "Tisch Montage", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Montage 1").MachineGroupId, HierarchyNumber = 10 }, // Tisch Platte new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Tisch-Platte").Id, Name = "Zuschneiden", Duration = 15, MachineGroupId = machines.Single(n => n.Name == "Montage 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Tisch-Platte").Id, Name = "Löcher vorbohren", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Montage 1").MachineGroupId, HierarchyNumber = 20 }, // Tisch Beine new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Tisch-Bein").Id, Name = "Zuschneiden", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Montage 1").MachineGroupId, HierarchyNumber = 10 }, new WorkSchedule { ArticleId = articles.Single(a => a.Name == "Tisch-Bein").Id, Name = "Löcher vorbohren", Duration = 2, MachineGroupId = machines.Single(n => n.Name == "Montage 1").MachineGroupId, HierarchyNumber = 20 }, }; context.WorkSchedules.AddRange(workSchedule); context.SaveChanges(); //create Businesspartner var businessPartner = new BusinessPartner() { Debitor = true, Kreditor = false, Name = "Toys'R'us Spielwarenabteilung" }; var businessPartner2 = new BusinessPartner() { Debitor = false, Kreditor = true, Name = "Material Großhandel" }; context.BusinessPartners.Add(businessPartner); context.BusinessPartners.Add(businessPartner2); context.SaveChanges(); var artToBusinessPartner = new ArticleToBusinessPartner[] { new ArticleToBusinessPartner { BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Holz 1,5m x 3,0m").Id, PackSize = 1, Price = 1, DueTime = 2 }, }; context.ArticleToBusinessPartners.AddRange(artToBusinessPartner); context.SaveChanges(); // Sim Config var simConfig = new SimulationConfiguration { Name = "Test config", Lotsize = 1, MaxCalculationTime = 120, // test // 10080, // 7 days OrderQuantity = 0, Seed = 1338, ConsecutiveRuns = 1, OrderRate = 0.25, //0.25 Time = 0, RecalculationTime = 1440, SimulationEndTime = 1000, DecentralRuns = 0, CentralRuns = 0, DynamicKpiTimeSpan = 120, SettlingStart = 0, WorkTimeDeviation = 0 }; context.SimulationConfigurations.Add(simConfig); context.SaveChanges(); var order = new Order { BusinessPartnerId = businessPartner.Id, CreationTime = 0, Name = "BeispielOrder 1", DueTime = 30 }; context.Add(order); context.SaveChanges(); var orderPart = new OrderPart { ArticleId = 1, Quantity = 1, OrderId = order.Id }; context.Add(orderPart); context.SaveChanges(); var order2 = new Order { BusinessPartnerId = businessPartner.Id, CreationTime = 0, Name = "BeispielOrder 2", DueTime = 50 }; context.Add(order2); context.SaveChanges(); var orderPart2 = new OrderPart { ArticleId = 1, Quantity = 1, OrderId = order2.Id }; context.Add(orderPart2); context.SaveChanges(); }