private void StartButton_Click(object sender, RoutedEventArgs e) { var stopwatch = new Stopwatch(); var noOfRabbitsToCreate = 1000; string firstTimeElapsed, secondTimeElapsed; stopwatch.Start(); using (var db = new RabbitDbEntities()) { for (int i = 1; i <= noOfRabbitsToCreate; i++) { Console.WriteLine(db.Rabbits.Find(i).RabbitID); } } firstTimeElapsed = stopwatch.Elapsed.ToString(); stopwatch.Stop(); stopwatch.Reset(); stopwatch.Start(); using (var db = new RabbitDbEntities()) { foreach (var rabbit in db.Rabbits.ToList()) { Console.WriteLine(rabbit.RabbitID); } } firstTimeElapsed = stopwatch.Elapsed.ToString(); stopwatch.Stop(); stopwatch.Reset(); stopwatch.Start(); for (int i = 1; i <= noOfRabbitsToCreate; i++) { using (var db = new RabbitDbEntities()) { Console.WriteLine(db.Rabbits.Find(i).RabbitID); } } secondTimeElapsed = stopwatch.Elapsed.ToString(); stopwatch.Stop(); stopwatch.Reset(); }