public ActionResult Index(PascalsPyramidModel model) { if (ModelState.IsValid) { using (var db = new YouConfDbContext()) { //Run it once to warm it up, that way we're actually testing the proc, and not the connection to SQL and Entity framework etc var nthRow = db.Database.SqlQuery<string>("exec GetPascalTriangleNthRow @RowNumber", new SqlParameter("@RowNumber", model.RowNumber)).First(); // Create new stopwatch Stopwatch stopwatch = new Stopwatch(); // Begin timing stopwatch.Start(); for (int i = 0; i < 10; i++) { db.Database.SqlQuery<string>("exec GetPascalTriangleNthRow @RowNumber", new SqlParameter("@RowNumber", model.RowNumber)).First(); } var elapsed = stopwatch.Elapsed; ViewBag.TotalTimeElapsed = elapsed; ViewBag.NthRow = nthRow; return View(model); } } return View(model); }
public void SetupTest() { //Database.SetInitializer<YouConfDbContext>(null); Database.SetInitializer(new DropCreateDatabaseAlways<YouConfDbContext>()); using (var context = new YouConfDbContext()) { context.Database.Initialize(true); } _context = new YouConfDbContext(); }
protected override void Seed(YouConf.Common.Data.YouConfDbContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }