title: Entity Framework Update - The context is not currently tracking the entity
body: <p>I am trying to update an entity but I am getting the following error:</p>
  
  <blockquote>
    <p>The context is not currently tracking the entity.</p>
  </blockquote>
  
  <p>My DB table consists of the following fields:</p>
  
  <blockquote>
    <p>fixturedate, leagueID (FK), Team A (FK), Team B (FK).</p>
  </blockquote>
  
  <p>My code is as follows:</p>
  
  <pre><code>public void UpdateFixture(Fixture validFixture)
  {
      Fixture fixture = new Fixture();
      fixture = entities.Fixtures.Where(f =&gt; f.fixtureId == validFixture.fixtureId).FirstOrDefault();
  
      League league = new League();
      league.LeagueId = validFixture.leagueId;
      fixture.League = leagueActions.GetLeague(league);
  
      fixture.Team1 = teamActions.GetTeam(validFixture.teamA);
      fixture.Team2 = teamActions.GetTeam(validFixture.teamB);
  
      entities.UpdateObject(validFixture);
      entities.SaveChanges();
  }
  </code></pre>
  
  <p>When I do <code>entities.AttachTo("Fixtures", validFixture);</code> I get the following error:</p>
  
  <blockquote>
    <p>The context is already tracking a different entity with the same resource Uri.</p>
  </blockquote>
  
  <p>What do I need to do to update the fixture entity?</p>