// This is the big ugly migration that contains all the logic for parsing the scraped wiki data // in the json files and inserting the database rows for items and spells. protected override void Up(MigrationBuilder migrationBuilder) { try { Console.WriteLine("Inserting item and spell data. This might take a few minutes... be patient and don't exit early!"); } catch { } var allItemsAndSpells = getAllItemsAndSpells(); using (var context = new TunnelQuestContext()) { using (var transaction = context.Database.BeginTransaction()) { try { // insert spells first context.AddRange(allItemsAndSpells.Spells); context.SaveChanges(); // insert items second context.AddRange(allItemsAndSpells.Items); context.SaveChanges(); transaction.Commit(); } catch { transaction.Rollback(); throw; } } // end using (transaction) } // end using (context) try { Console.WriteLine("Finished inserting item and spell data."); } catch { } } // end function
private void insertDeities(TunnelQuestContext context) { context.AddRange(getDeities()); }
// private helpers #region aliases private void insertAliases(TunnelQuestContext context) { context.AddRange(getAliases()); }
private void insertWeaponSkills(TunnelQuestContext context) { context.AddRange(getWeaponSkills()); }
private void insertEffectTypes(TunnelQuestContext context) { context.AddRange(getEffectTypes()); }
private void insertSlots(TunnelQuestContext context) { context.AddRange(getSlots()); }
private void insertAuthTokenStatuses(TunnelQuestContext context) { context.AddRange(getAuthTokenStatuses()); }