Are there any tools available, or perhaps utility methods within NHibernate, which may help me to nail down which mapping is throwing a “The given key is not present in the dictionary”?
I understand that I must have a bad mapping, but I have hundreds of domain objects. What can I do to locate the source of my error more quickly?
From the NHibernate 2.1.2GA Source:
private PersistentClass GetPersistentClass(string className)
{
PersistentClass pc = configuration.classes[className]; // <- "The given key was not present in the dictionary"
if (pc == null)
{
throw new MappingException("persistent class not known: " + className);
}
return pc;
}
And in this case, className is System.Int32.
Ok, so I had an int field marked <many-to-one> instead of <property>. I ended up digging up the source for NH and debugging to get to this point.
NHibernate Mapping: Creating Sanity Checks