I am getting an exception being thrown when a calling 'Get' (on a navigation property) when the child's FK is also it's PK (0-1 <-> 1 [pk of table]). I am also getting this with self referential associations (and assuming that it is supported since the EDM picked it up).
Here is the stack trace when the navigation property was accessed. Which was hard to track down, because it was being accessed because the entities properties were individually bound to an interface grid cell (the get call to the navigation property popped the exception). As the stack trace below illustrates it really doesn't get past the get call.
This table has a FK key back to a another table and that happens to be the pk of the table too. I don't get to control that... but I have to deal with it... :P
Is 5.0.6 my fix? I am using 5.0.3 right now. Is 5.0.5 a fix? I am going to try in any case (nothing left to do...).
Do let me know if you can use any more info.
===Stack Trace===
System.InvalidOperationException occurred
Message=You may not change the entity’s EntityKey (currently
‘ElementHistory: -9223372036854747107’) while any of its related, dependent
entities are in the entity cache. Are you sure you want to change the EntityKey?
Consider reordering your operations such that you set the EntityKey first.
Alternatively you could detach the entity or remove its dependent entities
before trying again but be aware that you risk orphaning the dependent
entities.
Source=IdeaBlade.EntityModel
StackTrace:
at
IdeaBlade.EntityModel.ScalarEntityReference`1.UpdateOtherProperties(EntityRelationLink
relationLink, EntityWrapper fromEntity, EntityWrapper toEntity)
at
IdeaBlade.EntityModel.ScalarEntityReference`1.UpdateFkForNewToEntity(EntityWrapper
toEntity)
at IdeaBlade.EntityModel.ScalarEntityReference`1.SetEntity(T
newValue, Boolean updateFkValues, Boolean updateInverseValues)
at
IdeaBlade.EntityModel.ScalarEntityReference`1.AddEntity(Object entity, Boolean
updateInverseValues)
at
IdeaBlade.EntityModel.RelatedEntityList`1.AddInverse(T otherEntity)
at
IdeaBlade.EntityModel.RelatedEntityList`1.AddOrInsert(Int32 index, T item,
Boolean updateInverse)
at
IdeaBlade.EntityModel.RelatedEntityList`1.Add(T item, Boolean
updateInverse)
at
IdeaBlade.EntityModel.ListEntityReference`1.AddEntity(Object entity, Boolean
updateInverse)
at
IdeaBlade.EntityModel.ListEntityReference`1.FixupReferences()
at
IdeaBlade.EntityModel.EntityWrapper.<FixupReferences>b__13(EntityReferenceBase
eref)
at IdeaBlade.Core.EnumerableFns.ForEach[T](IEnumerable`1 items,
Action`1 action)
at
IdeaBlade.EntityModel.EntityWrapper.FixupReferences()
at
IdeaBlade.EntityModel.EntityWrapper.TrackChanged(EntityChangedEventArgs e)
at IdeaBlade.EntityModel.EntityGroup.OnEntityChanged(EntityChangedEventArgs
e)
at IdeaBlade.EntityModel.EntityGroup.AddQueriedEntity(EntityWrapper
wrapper)
at IdeaBlade.EntityModel.EntityGroup.LoadEntity(EntityWrapper
sourceWrapper, MergeStrategy mergeStrategy, Boolean& rowUpdated)
at IdeaBlade.EntityModel.EntityMerger.MergeEntityCore(EntityWrapper
sourceWrapper, EntityGroup targetEntityGroup)
at
IdeaBlade.EntityModel.EntityMerger.MergeEntity(EntityWrapper sourceWrapper,
EntityGroup targetEntityGroup, NavigationContext context)
at
IdeaBlade.EntityModel.EntityMerger.<>c__DisplayClass1.<MergeEntities>b__0(EntityWrapper
sourceWrapper)
at
System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource
x)
at
System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at
IdeaBlade.Core.EnumerableFns.ForEach[T](IEnumerable`1 items, Action`1
action)
at IdeaBlade.EntityModel.DataBlockFns.MakeResultList(Type
type, IEnumerable items, Boolean isOrdered)
at
IdeaBlade.EntityModel.EntityQueryResult.UpdateDataSet(EntitiesDataBlock block,
NavigationContext context)
at
IdeaBlade.EntityModel.EntitiesDataBlock.Resolve(EntityQueryResult helper)
at IdeaBlade.EntityModel.EntityQueryResult..ctor(DataQueryResult
dataQueryResult, EntityManager entityManager, MergeStrategy mergeStrategy, Guid
queryId, QueryInfo queryInfo)
at
IdeaBlade.EntityModel.EntityQueryResultCollection..ctor(DataQueryResultCollection
dqResults, EntityManager entityManager, MergeStrategy mergeStrategy)
at
IdeaBlade.EntityModel.EntityManager.MergeAndReturnDataSourceOnly(IEntityFinder
finder, DataQueryResultCollection dqResults)
at
IdeaBlade.EntityModel.EntityManager.ProcessFetchedData(DataQueryResultCollection
dqResults, IEntityFinder finder)
at
IdeaBlade.EntityModel.EntityManager.ExecuteFetch(IEntityFinder finder)
at IdeaBlade.EntityModel.EntityKeyFinder.Execute()
at
IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean
isAsync)
at
IdeaBlade.EntityModel.EntityManager.ExecuteQuery(IEntityQuery query)
at IdeaBlade.EntityModel.EntityManager.FirstOrNullEntity(IEntityQuery
query)
at
IdeaBlade.EntityModel.EntityQueryExtensions.FirstOrNullEntity(IEntityQuery
query)
at
IdeaBlade.EntityModel.ScalarEntityReference`1.QueryForEntity(EntityReferenceStrategy
strategy)
at
IdeaBlade.EntityModel.ScalarEntityReference`1.GetEntity(EntityReferenceStrategy
strategy)
at
IdeaBlade.EntityModel.ScalarEntityReference`1.GetValue()
at
IdeaBlade.EntityModel.NavigationScalarEntityProperty`2.<.ctor>b__0(NavigationEntityPropertyGetInterceptorArgs`2
args)
at IdeaBlade.Core.PropertyInterceptor`3.HandleAction(Action`1
action, TArgs args)
at
IdeaBlade.Core.PropertyInterceptor`3.<BuildTargetedCombinedAction>b__3(TArgs
args)
at IdeaBlade.Core.PropertyInterceptor`3.ExecuteActions(TArgs
args)
at IdeaBlade.Core.PropertyInterceptor`3.GetValue(TInstance
instance, Object context)
at
IdeaBlade.Core.PropertyInterceptor`3.GetValue(TInstance instance)
at
IdeaBlade.EntityModel.NavigationScalarEntityProperty`2.GetValue(TInstance
instance)
at Dal.Model.ElementSummary.get_ElementHistory()