private void InitializeLandmarksAndTowers(FantasyContext context, IEnumerable <Province> provinces) { var province1 = provinces.Where(h => h.Name == "Province1").Single(); var province2 = provinces.Where(h => h.Name == "Province2").Single(); var pilchukSummit = new Landmark { Id = 1, LocatedIn = province1, }; var grayLighthouse = new Landmark { Id = 2, LocatedIn = province2, }; var highTower = new Tower { Id = 3, LocatedIn = province1, }; var stoneTower = new Tower { Id = 4, LocatedIn = province2, }; pilchukSummit.MatchingTower = highTower; grayLighthouse.MatchingTower = stoneTower; context.Landmarks.AddRange(new[] { pilchukSummit, grayLighthouse }); context.Towers.AddRange(new[] { highTower, stoneTower }); }
public void Seed(FantasyContext context) { var creatures = InitializeCreatures(); context.Creatures.AddRange(creatures); context.SaveChanges(); var skills = InitializeSkills(); context.Skills.AddRange(skills); context.SaveChanges(); var races = InitializeRaces(skills); context.Races.AddRange(races); context.SaveChanges(); var illusionPerks = InitializerIllusionPerks(skills.Single(s => s.Name == "Illusion")); context.Perks.AddRange(illusionPerks); context.SaveChanges(); var spells = InitializeSpells(); context.Spells.AddRange(spells); context.SaveChanges(); var provinces = InitializeProvinces(); InitializeLandmarksAndTowers(context, provinces); var cities = InitializeCities(provinces); var npcs = InitializeNpcs(races); var buildings = InitializeBuildings(cities, npcs); context.Provinces.AddRange(provinces); context.Cities.AddRange(cities); context.Npcs.AddRange(npcs); context.Buildings.AddRange(buildings); context.SaveChanges(); }
private void InitializeLandmarksAndTowers(FantasyContext context, IEnumerable<Province> provinces) { var province1 = provinces.Where(h => h.Name == "Province1").Single(); var province2 = provinces.Where(h => h.Name == "Province2").Single(); var pilchukSummit = new Landmark { Id = 1, LocatedIn = province1, }; var grayLighthouse = new Landmark { Id = 2, LocatedIn = province2, }; var highTower = new Tower { Id = 3, LocatedIn = province1, }; var stoneTower = new Tower { Id = 4, LocatedIn = province2, }; pilchukSummit.MatchingTower = highTower; grayLighthouse.MatchingTower = stoneTower; context.Landmarks.AddRange(new[] { pilchukSummit, grayLighthouse }); context.Towers.AddRange(new[] { highTower, stoneTower }); }