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

  • Question

  • 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();
        }

    • Moved by Lisa Zhu Monday, December 3, 2012 7:06 AM EF related (From:Visual C# Language)
    Friday, November 30, 2012 3:05 PM

Answers

  • got it by my own here is the answer 

    http://stackoverflow.com/questions/13647165/sys-webforms-pagerequestmanagerservererrorexception-an-entity-object-cannot-be/13704971#13704971

    • Edited by Nikola12 Tuesday, December 4, 2012 2:22 PM
    • Marked as answer by Nikola12 Tuesday, December 4, 2012 2:22 PM
    Tuesday, December 4, 2012 9:39 AM

All replies