NHibernate.MappingException: Unknown entity class

If you get MappingException error, there are two things you should check out:

  • Make sure the name of the *.hbm.xml is spelled correctly — not *.hmb.xml nor *.mbh.xml
  • Make sure the Build Action property is set to “Embeded Resource.”

I learned this the hard way. First, I wrongly spelled hbm.xml and I had its Buld Action property set to “Content”. The above 2 points fixed the problem.

Credit: VerySimple, Inc


3 thoughts on “NHibernate.MappingException: Unknown entity class

  1. Ken, not sure the reason behind choosing an XML file but if you do use Castle stack you can take benefit from ActiveRecord attributes and get rid off XML, unless you want to purify your Model (which I don’t :)).

    • Oh, I recently began to pick up NHibernating after seeing how cool it was during the the MonoRail based web development. Reading through the documentation as well as being a noob on this, I just use XML for now. Thanks for the recommendation on ActiveRecord, I’ll be checking it out very soon. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

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