An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Attaching an entity of type 'WebLanguageTeacher.Models.MyDatabase.Word' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.
This is how it looks like:
var getWordfromDB = db.Words.Find(word.ID);
word.NextReview = getWordfromDB.NextReview;
word.LastReviewed = getWordfromDB.LastReviewed;
db.Entry(word).State = EntityState.Modified;
I'm making some changes in "Word" object. For some reasons I have to get data from database and put it again to the same object. Without using Find() method, EntityState.Modified works, but when I placed it there, it throws this error.
How to fix that?