Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Bookmarks.Data;
- using System.Diagnostics;
- namespace BulkGenerator
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch myTimer = new Stopwatch();
- myTimer.Start();
- InsertUsers(30000);
- myTimer.Stop();
- Console.WriteLine(myTimer.Elapsed);
- }
- private static void InsertUsers(int count)
- {
- var context = new BookmarksEntities();
- context.Configuration.AutoDetectChangesEnabled = false;
- context.Configuration.ValidateOnSaveEnabled = false;
- var initialCount = context.Users.Count();
- for (int i = initialCount + 1; i < initialCount + count; i++)
- {
- User newUser = new User { Username = "User" + i };
- context.Users.Add(newUser);
- if (i % 100 == 0)
- {
- context.SaveChanges();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement