title: Entity Framework,There is already an open DataReader associated with this Connection which must be closed first
body: <p>In the "each", when run the "FirstOrDefault" will error "There is already an open DataReader associated with this Connection which must be closed first.".
  How to do ?</p>
  
  <pre><code>public int SetUser(string[] dIds, string pId)
  {
      using (var scope = _dbContextScopeFactory.Create())
      {
          var db = scope.DbContexts.Get&lt;JuCheapContext&gt;();
  
          var users = db.Users;
  
          var user = users.FirstOrDefault(m =&gt; m.Id == pId);
          if (user.Places == null)
          {
              user.Places = new List&lt;PlaceEntity&gt;();
          }
  
          var place = db.Place.Include(m =&gt; m.User).Where(m =&gt; dIds.Contains(m.Id));
  
          place.Each(m =&gt;
          {
              user.Places.Add(m);
  
              //There is already an open DataReader associated with this Connection which must be closed first.
              var pu = users.FirstOrDefault(u =&gt; u.LoginName == m.Key);
  
              if (pu != null)
              {
                  pu.FId = pId;
              }
  
          });
  
          return db.SaveChanges();
      }
  }
  </code></pre>