0

Consider the following code:

var courseName=DbContext.SingleInstance().Entities.tblCourse.ToList();
DbContext.SingleInstance().Entities.ChangeDatabase(ECourse.SingleInstance.CourseNameTable);
DbContext.SingleInstance().CourseEntities.tblCourse.AddRange(courseName);
DbContext.SingleInstance().CourseEntities.SaveChanges();

DbContext.SingleInstance().CourseEntities.tblCourse.AddRange(courseName);

This row is An entity object cannot be referenced by multiple instances of IEntityChangeTracker error.

tblCourse is relations one to many other tables.

How can I solve this problem?

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
K.E
  • 23
  • 1
  • 7
  • 1
    Welcome to Stack Overflow! *Be sure to research your error and question before you ask it.* Often you'll find an answer before you finish writing your question. For instance, I googled `IEntityChangeTracker error` just to see what language you were talking about, and I found [this great post](https://stackoverflow.com/questions/10191734/entity-object-cannot-be-referenced-by-multiple-instances-of-ientitychangetracker) with the same error as yours. – Travis Heeter Sep 28 '18 at 13:15
  • Possible duplicate of [entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1](https://stackoverflow.com/questions/10191734/entity-object-cannot-be-referenced-by-multiple-instances-of-ientitychangetracker) – Travis Heeter Sep 28 '18 at 13:15

0 Answers0