Note that there are some explanatory texts on larger screens.

plurals
  1. POEF WPF DataGrid Reload causes InvalidOperationException: why?
    primarykey
    data
    text
    <p>I have a <code>EF 4</code> POCO DbContext and am showing a table in a <code>DataGrid</code> <code>(System.Windows.Controls.DataGrid)</code>.</p> <ol> <li>I can <code>SaveChanges</code> to store changes made in the <code>DataGrid</code>.</li> <li>I can <code>Reload()</code> to get data updated by another user (ie me using <code>SQL Management Studio</code>).</li> <li>I can then see the other user's data</li> </ol> <p>However, if I try to do 1 <em>then</em> 2 (i.e. make a change in the grid, <code>SaveChanges</code>, after that another user changes the data then I Reload) I get an <code>InvalidOperationException</code>.</p> <p>This happens only when changing the text through the grid, not when changing the data through code.</p> <p>I can quietly swallow the exception and then see the updated data. However I'd rather not do that without understanding what's going on...</p> <p>What's going on?</p> <p>The complete exception is...</p> <blockquote> <p>System.InvalidOperationException occurred HResult=-2146233079 Message=EntityMemberChanged or EntityComplexMemberChanged was called without first calling EntityMemberChanging or EntityComplexMemberChanging on the same change tracker with the same property name. For information about properly reporting changes, see the Entity Framework documentation. Source=System.Data.Entity StackTrace: at System.Data.Objects.EntityEntry.EntityMemberChanged(String entityMemberName, Object complexObject, String complexObjectMemberName) at System.Data.Objects.EntityEntry.EntityMemberChanged(String entityMemberName) at System.Data.Objects.ObjectStateEntry.System.Data.Objects.DataClasses.IEntityChangeTracker.EntityMemberChanged(String entityMemberName) at System.Data.Objects.Internal.SnapshotChangeTrackingStrategy.SetCurrentValue(EntityEntry entry, StateManagerMemberMetadata member, Int32 ordinal, Object target, Object value) at System.Data.Objects.Internal.EntityWrapper<code>1.SetCurrentValue(EntityEntry entry, StateManagerMemberMetadata member, Int32 ordinal, Object target, Object value) at System.Data.Objects.EntityEntry.SetCurrentEntityValue(StateManagerTypeMetadata metadata, Int32 ordinal, Object userObject, Object newValue) at System.Data.Objects.ObjectStateEntryDbUpdatableDataRecord.SetRecordValue(Int32 ordinal, Object value) at System.Data.Objects.EntityEntry.UpdateRecord(Object value, DbUpdatableDataRecord current, UpdateRecordBehavior behavior, Int32 propertyIndex) at System.Data.Objects.Internal.SnapshotChangeTrackingStrategy.UpdateCurrentValueRecord(Object value, EntityEntry entry) at System.Data.Objects.Internal.EntityWrapper</code>1.UpdateCurrentValueRecord(Object value, EntityEntry entry) at System.Data.Common.Internal.Materialization.Shaper.UpdateEntry[TEntity](IEntityWrapper wrappedEntity, EntityEntry existingEntry) at System.Data.Common.Internal.Materialization.Shaper.HandleEntity[TEntity](IEntityWrapper wrappedEntity, EntityKey entityKey, EntitySet entitySet) at lambda_method(Closure , Shaper ) at System.Data.Common.Internal.Materialization.Coordinator<code>1.ReadNextElement(Shaper shaper) at System.Data.Common.Internal.Materialization.Shaper</code>1.SimpleEnumerator.MoveNext() at System.Data.Objects.ObjectContext.BatchRefreshEntitiesByKey(RefreshMode refreshMode, Dictionary<code>2 trackedEntities, EntitySet targetSet, List</code>1 targetKeys, Int32 startFrom) at System.Data.Objects.ObjectContext.RefreshEntities(RefreshMode refreshMode, IEnumerable collection) at System.Data.Objects.ObjectContext.Refresh(RefreshMode refreshMode, Object entity) at System.Data.Entity.Internal.InternalEntityEntry.Reload() at System.Data.Entity.Infrastructure.DbEntityEntry.Reload() at Chilli.Model.ObjectContext.SafeReload(Object o) in c:\projects\MyProject\Chilli.Model\ObjectContext_Refresh.cs:line 19 InnerException: </p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload