nhibernate “refers to an unmapped class: System.String”

Came across this error today. It had me confused for a few minutes but it was an easy one to resolve and highlights a potential pitfall with copy/paste of entity maps.
I’m mapping data from an external database into my main app’s repository.

The external datasource has a composite key of 3 fields and these fields have names with suffixes of ‘id’ but they’re strings not ints.

My mapping file had something like

.KeyReference(x => x.Mod_id)
.KeyReference(x => x.Year_id)
.KeyReference(x => x.Prog_id);

‘KeyReference’ was the issue. As the fields / properties were strings I had to change them to ‘KeyProperty’.

.KeyProperty(x => x.Mod_id)
.KeyProperty(x => x.Year_id)
.KeyProperty(x => x.Prog_id);


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s