I am trying to clear all the elements from the Entity Framework collection, in this case remove all the food from the plate. Any ideas how I can solve the following: the code below raises an error:
An exception of type "System.InvalidOperationException" occurred in EntityFramework.dll, but was not processed in the user codeAdditional information: object-object cannot refer to several instances of IEntityChangeTracker.
An exception of type "System.InvalidOperationException" occurred in EntityFramework.dll, but was not processed in the user code
Additional information: object-object cannot refer to several instances of IEntityChangeTracker.
Plate selPlate = (Plate)Session["selPlate"]; foreach (FoodForPlate f in selPlate.FoodForPlates) { context.Entry(f).State = System.Data.Entity.EntityState.Deleted; } context.SaveChanges(); bindstats(); UpdatePanel1.Update();
The Entity Framework tracks your loaded items to detect changes, and you already have some of these objects. Try:
dbContext.Entry(entity).State = EntityState.Detached;
, .
Source: https://habr.com/ru/post/1531783/More articles:using vim as a C ++ 11 IDE - c ++Last access time for files on Android - androidStacking data.frames в списке в один файл data.frame, сохраняя имена (список) в качестве дополнительного столбца - rПовторная выборка временных рядов событий + длительность в параллельные события - pythonDraw a hand using splines (Matlab) - matlabInterpolating a trajectory from an unsorted array of two-dimensional points, where order matters - arraysConfiguring Jenkins with StartSSL - Adding an Issuer Chain - sslFinal builder for Jest - elasticsearchIn python, why not use, with the exception of: - pythonExpose different types of names (smoothing) from the assembly - c #All Articles