title: An entity object cannot be referenced by multiple instances of IEntityChangeTracker EF6
body: <p>I have the following code where it seems that userManager creates a different DBContext and my companyListService uses different DbContext. As a result I get the error message saying </p>
  
  <blockquote>
    <p>An entity object cannot be referenced by multiple instances of
    IEntityChangeTracker</p>
  </blockquote>
  
  <pre><code>           if (ModelState.IsValid)
              {
                  try
                  {
                      _companyListService.AddCompanyList(
                      new CompanyList(_userManager.FindById(GetUserId()), vm.Name));
  
                     _companyListService.SaveCompanyList();
                  }
                  catch (Exception e)
                  {
                      _nlogger.Error(e);
  
                      ViewData["EditError"] = e.Message;
                  }
              }
  </code></pre>
  
  <p>How could I fix this problem? Is there any way stop tracking in userManager dbcontext? Or a better way to use the same dbcontext? The application uses Identity 2. </p>
  
  <p>I can change my code to pass the userId instead of user object which solves the problem but I would like to pass the user object in. </p>
  
  <p>When I turn off the tracking by </p>
  
  <pre><code>Configuration.AutoDetectChangesEnabled = false;
  </code></pre>
  
  <p>The issue is also resolved but this would break other parts as tracking us required. </p>
  
  <p>What is the best way to overcome this issue? </p>
  
  <p>Thanks,</p>