static void CleanupDB() { using (var context = new DMContext()) { context.Database.ExecuteSqlCommand("delete from Factors"); context.Database.ExecuteSqlCommand("delete from Categories"); context.SaveChanges(); } }
static void WriteToDB(int numberOfFactors) { var stopWatch = new Stopwatch(); var category = CreateCategory(); var factors = new List<Factor>(numberOfFactors); for (int iterator = 1; iterator < numberOfFactors; iterator++) { factors.Add(CreateFactor(category, iterator)); } using (var context = new DMContext()) { stopWatch.Start(); context.Categories.Add(category); context.Factors.AddRange(factors); context.SaveChanges(); stopWatch.Stop(); } Console.WriteLine("Writing of {0} factors to DB took {1} ms", numberOfFactors, stopWatch.ElapsedMilliseconds); }