public void TestOneAddAndSaveChanges() { //SETUP var options = this.CreateUniqueClassOptions <Chapter14DbContext>(); using var context = new Chapter14DbContext(options); context.Database.EnsureClean(); //ATTEMPT using (new TimeThings(_output, "One Add and one SaveChanges")) { var list = new List <MyEntity>(); for (int i = 0; i < 100; i++) { list.Add(new MyEntity()); } context.AddRange(list); context.SaveChanges(); } using (new TimeThings(_output, "One Add and one SaveChanges")) { var list = new List <MyEntity>(); for (int i = 0; i < 100; i++) { list.Add(new MyEntity()); } context.AddRange(list); context.SaveChanges(); } using (new TimeThings(_output, "One Add and one SaveChanges")) { var list = new List <MyEntity>(); for (int i = 0; i < 100; i++) { list.Add(new MyEntity()); } context.AddRange(list); context.SaveChanges(); } //VERIFY }
private void AddMyEntities(Chapter14DbContext context, int numToAdd) { var list = new List <MyEntity>(); for (int i = 0; i < numToAdd; i++) { list.Add(new MyEntity()); } context.AddRange(list); context.SaveChanges(); }