This is a migrated thread and some comments may be shown as answers.

Sys.WebForms.PageRequestManagerServerErrorException: An entity object cannot be referenced by multiple instances of IEntityChangeTracker

1 Answer 399 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 2
Nikola asked on 30 Nov 2012, 02:44 PM

Heely Guys

Story: I have a strange error when I try to save something I got this error message ( An entity object cannot be referenced by multiple instances of IEntityChangeTracker.)
I really don’t know what that is and why is it appear, it appears only when I try to save something my insert and update is working, only when I try to save something in db from my grid



if (this.annualVacationList != null)
      {
          List<AnnualVacation> vacationToSave = this.annualVacationList;
          IEnumerable<AnnualVacation> existing = paramUser.AnnualVacations;
          foreach (AnnualVacation toSave in vacationToSave)
          {
              AnnualVacation existingItem = existing.Where(x => x.AnnualVacationId == toSave.AnnualVacationId).SingleOrDefault();
              if (existingItem == null)
              {
                  ctx.AddToAnnualVacations(toSave);
              }
              else
              {
                  existingItem.FromDate = toSave.FromDate;
                  existingItem.ToDate = toSave.ToDate;
                  existingItem.WorkingTime = toSave.WorkingTime;
                  existingItem.VacationDays = toSave.VacationDays;
              }
          }
      }
      ctx.SaveChanges();
  }

After debugging I have seen that the code brake down in the Project.Name.Designer.cs ..... O.o


public void AddToAnnualVacations(AnnualVacation annualVacation)
   {
       base.AddObject("AnnualVacations", annualVacation);
   }




1 Answer, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 05 Dec 2012, 11:37 AM
Hello Nikola,

The presented error is mostly a generic issue and not directly related to the RadControls. I would suggest you to review the online resources below which elaborates on this error:

http://social.msdn.microsoft.com/Forums/en-SG/adodotnetentityframework/thread/501d7b99-0cb9-44b6-b2cd-16275a151b31
http://stackoverflow.com/questions/620084/how-to-get-rid-off-an-entity-object-cannot-be-referenced-by-multiple-instances
http://forums.asp.net/t/1587926.aspx/1

Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Nikola
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
Share this question
or