private static void DumpDatabaseData() { using (var context = new VehicleStoreContext()) { var branchesWithRevenues = context.Branches.Include(b => b.Revenues); foreach (var branch in branchesWithRevenues) { Console.WriteLine(branch); } } }
private static void SaveDataIntoDatabase(IEnumerable <BranchEntity> data) { using (var context = new VehicleStoreContext()) { foreach (var branch in data) { context.Branches.Add(branch); } context.SaveChanges(); } }
private static void ClearDatabase() { using (var context = new VehicleStoreContext()) { var deleteRevenuesSql = $"DELETE FROM {MonthlyRevenueEntity.TableName}"; context.Database.ExecuteSqlCommand(deleteRevenuesSql); var deleteBranchesSql = $"DELETE FROM {BranchEntity.TableName}"; context.Database.ExecuteSqlCommand(deleteBranchesSql); } }