title: Collection was modified; enumeration operation may not execute. Exception
body: <p>this code give me and Exception </p>
  
  <p><strong>Collection was modified; enumeration operation may not execute</strong></p>
  
  <p>i use Entity Framework to work with data</p>
  
  <pre><code>            foreach (OfflineMessage omc in _offMsgs)
              {
  
                  var OimDB = new OimDBEntities();
  
                  if (omc.MsgTo == e.MessageData.ToHeader.Uri)
                  {
                      var offlineMessage = new OfflineMessage
                      {
                          Delivered = false,
                          MsgContent = omc.MsgContent,
                          MsgFrom = omc.MsgFrom,
                          MsgTime = omc.MsgTime,
                          MsgTo = omc.MsgTo,
                          ID = OimDB.OfflineMessages.NextId(f =&gt; f.ID)
  
                      };
  
                      oimRepository.InsertOIM(offlineMessage);
  
                      //InsertData(omc.MsgFrom, omc.MsgTo, omc.MsgContent, omc.MsgTime);
                  }
              }
              _toHeader = e.MessageData.ToHeader.Uri;
          }
  </code></pre>