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 to kevin Cancel reply