Я пытаюсь обновить объект, но я получаю следующее сообщение об ошибке:Entity Framework Update - контекст в настоящее время не отслеживает объект
The context is not currently tracking the entity.
Моя DB таблица состоит из следующих полей:
fixturedate, leagueID (FK), Team A (FK), Team B (FK).
Мой код выглядит следующим образом:
public void UpdateFixture(Fixture validFixture)
{
Fixture fixture = new Fixture();
fixture = entities.Fixtures.Where(f => 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();
}
Когда я entities.AttachTo("Fixtures", validFixture);
я получаю FOLLO крыла:
The context is already tracking a different entity with the same resource Uri.
Что нужно сделать, чтобы обновить объект крепления?
Привет, Карко, ты прав. Пришлось обновить реальный светильник! большое спасибо – Johann