title: Entity object cannot be referenced by multiple instances
body: <p>I am inserting some objects into the database, but getting the following errors:</p>
  
  <blockquote>
    <p>An exception of type 'System.InvalidOperationException' occurred in
    System.Data.Entity.dll but was not handled in user code</p>
    
    <p>Additional information: An entity object cannot be referenced by
    multiple instances of IEntityChangeTracker.</p>
  </blockquote>
  
  <p>I have tried to research and find the issue, but couldn't find proper way of resolving and understanding the issue. Any help is appreciated. </p>
  
  <p>Here is small source part that causes the error:</p>
  
  <pre><code>SysUsers User = GetUser()
  foreach (int country in data.countries) {
          foreach (int street in data.streets)
          {
              BrowsedData tempBrowsed = new BrowsedData();
              MapInfo tempInformation = WorldInformationController.FindInformation(country, street);
              tempBrowsed.Information = tempInformation;
              tempBrowsed.User = User;
              tempBrowsed.UpdatedBy = User;
              tempBrowsed.sDateTime = data.IndividualFiscalYearEnds
                                  .Where(a =&gt; a.C_ID == country)
                                  .Select(a =&gt; a.LastDate).FirstOrDefault();
              this.Database.BrowsedData.Add(tempBrowsed);
              this.Database.SaveChanges();
          }
      }
  </code></pre>
  
  <p>The error denotes to this line: <code>this.Database.BrowsedData.Add(tempBrowsed);</code></p>