出于某种原因,导航属性不适用于我的实体框架模型。为什么RelationshipManager.GetRelatedReference <T>(,)总是返回空值为EntityReference <T>?
From the direction N->1
,每次我试图获得一个EntityReference它都带有空值,即使EntityKey是正确的。
From the direction 1->N
,集合总是空的。
此行为在整个模型中都是一致的。
不管是什么原因,我认为它应该引发一个默默检索不一致引用的异常intead。
引用会出现空值的可能原因是什么?
编辑
我只注意到它是与延迟加载。 EntityReference(T)随IsLoaded属性设置为false而显式调用Load方法解决该问题。问题在于访问导航属性时调用的方法RelationshipManager.GetRelatedReference
应该加载EntityReference。应该吗?