private static void RunAddAndSaveChangesOptimizedTest() { Console.WriteLine("Add 1K & SaveChanges (EF6 Optimized)"); RunTest( () => { using (var db = new PerformanceEf6.EF6.Context.AdventureWorksContext()) { db.Configuration.AutoDetectChangesEnabled = false; var categories = new PerformanceEf6.EF6.Models.ProductCategory[1000]; for (int i = 0; i < 1000; i++) { categories[i] = new PerformanceEf6.EF6.Models.ProductCategory { Name = $"Test {Guid.NewGuid()}" }; } db.ProductCategories.AddRange(categories); db.SaveChanges(); } }, () => { using (var db = new PerformanceEfCore.EfStructures.Context.AdventureWorksContext()) { for (int i = 0; i < 1000; i++) { db.ProductCategories.Add(new PerformanceEfCore.EfStructures.Models.ProductCategory { Name = $"Test {Guid.NewGuid()}" }); } db.SaveChanges(); } }); }
private static void RunAddAndSaveChangesTest() { Console.WriteLine("Add 1K & SaveChanges"); RunTest( TestEf6.AddRecordsAndSave, () => { using (var db = new PerformanceEfCore.EfStructures.Context.AdventureWorksContext()) { for (int i = 0; i < 1000; i++) { db.ProductCategories.Add(new PerformanceEfCore.EfStructures.Models.ProductCategory { Name = $"Test {Guid.NewGuid()}" }); } db.SaveChanges(); } }); }