I have a solution with 8 entity models and 5 projects, when I recompile the solution xaml crashes giving me "An item with the same key has already been added." I was able to debug my xaml and it appears to be entity framework related. The CreateObjectSet fails on several object entity throwing the exception below. Right now this happens only with the same entity object which is a view but I've seen that before with other types such as stored procedures and it was happened also during the runtime but exception was catch. I already check checked my solution and I don't have any duplicate vw_MyClass. Do you have any idea?
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=An EdmType cannot be mapped to CLR classes multiple times. The EdmType is mapped more than once.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.AddLoadedTypes(Dictionary2 typesInLoading) at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action
1 logLoadMessage)
at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)
at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly)
at System.Data.Entity.Core.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)
at System.Data.Entity.Core.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName)
at System.Data.Entity.Core.Objects.ObjectContext.CreateObjectSet[TEntity](String entitySetName)
This exception was originally thrown at this call stack: [External Code]
Inner Exception 1: ArgumentException: An item with the same key has already been added.
User contributions licensed under CC BY-SA 3.0