问题描述
我有一个包含8个实体模型和5个项目的解决方案,当我重新编译该解决方案时,xaml崩溃,提示我“ 已添加具有相同密钥的项目。”,我能够调试我的解决方案xaml,它似乎与实体框架有关。 CreateObjectSet 对多个对象实体失败,引发以下异常。现在,这种情况仅发生在同一个实体对象(即视图)上,但是我已经看到过,在其他类型(例如存储过程)之前,这种情况也发生在运行时,但是捕获到异常。我已经检查了解决方案,没有重复的vw_MyClass。 你有什么主意吗?
public ObjectSet<vw_MyClass> vw_MyClass
{
get
{
if ((_vw_MyClass == null))
{
_vw_MyClass = base.CreateObjectSet<vw_MyClass>("vw_MyClass");
}
return _vw_MyClass;
}
}
private ObjectSet<vw_MyClass> _vw_MyClass;
System.Data.Entity.Core.MappingException
HResult = 0x80131501
Message =一个EdmType不能多次映射到CLR类。 EdmType被多次映射。
来源= EntityFramework
堆栈跟踪:
在System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.AddLoadedTypes(Dictionary 2 typesInLoading) at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(Assembly assembly,Boolean loadReferencedAssemblies,EdmItemCollection edmItemCollection,Action
1 logLoadMessage)处
在System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(类型类型,EdmItemCollection edmItemCollection)
在System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(类型类型,程序集callingAssembly)
在System.Data.Entity.Core.Objects.ObjectContext.GetTypeUsage(TypeEntityCLRType)
在System.Data.Entity.Core.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName,Type entityCLRType,String exceptionParameterName)处
在System.Data.Entity.Core.Objects.ObjectContext.CreateObjectSet [TEntity](StringEntitySetName)处
此异常最初是在此调用堆栈上抛出的: [外部代码]
内部异常1: ArgumentException:具有相同键的项已添加。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)