title: How to quick insert data to sql server? When I use while cicle Its begin fast but after 5000 lines its' going to be very slowly
body: <p>When I try to write 100,000 lines to a database, I encounter very slow processing in the data cycle. I used lazy queries earlier and used the "AsNoTracking()" method, but it did not help. What's more, who can explain this phenomenon, when the loop has just started, when it goes through the loop pretty quickly, but as soon as it exceeds 5000 lines, the addition to the parameter is almost a second for each iteration?</p>
  
  <pre><code>`while (enumerator.MoveNext())
  {
      MonitorlControlTable dt = enumerator.Current as MonitorlControlTable;
      var user = users.Where(x =&gt; x.Name == dt.UserNameTb).FirstOrDefault();
      var action = actions.Where(x =&gt; x.Name == dt.ActionTb.Value.ToString()).FirstOrDefault();
      var project = projects.Where(x =&gt; x.Name == dt.ProjectNameTb).FirstOrDefault();
      var transaction = transactions.Where(x =&gt; x.Name == dt.TransactioNameTb).FirstOrDefault();
      TransactionBoard transactBoard = dbContext.TransactionBoard.Add(new TransactionBoard
  {
      User = user != null ? user : new EF.User { Name = dt.UserNameTb },
      Action = action != null ? action : new EF.Action { Name = dt.ActionTb.Value.ToString() },
      Project = project != null ? project : new Project { Name = dt.ProjectNameTb, Path = dt.ProjectNameTb },
    Transaction = transaction != null ? transaction : new Transaction { Name = dt.TransactioNameTb },
  DateTime = dt.WriteDateTimeTb.Value
    });
  dbContext.MonitorControl.Add(new MonitorControl
    {
      ElementId = dt.ElementIdTb.Value,
      Category = category.Where(x =&gt; x.Id == dt.CategoryIdTb).FirstOrDefault(),
      TransactionBoard = transactBoard
    });
    });
  }`
  </code></pre>
  
  <p>What I did wrong?</p>