Configuring Fluent NHibernate with an External NHibernate Config File

A while ago I was having issues using configuring fluent NHibernate with an external configuration file. I kept running into the issue of mappings not being registered. I was finally able to get it working appropriately and thought I would share my solution. The key is to configure the normal mappings first and then pass that configuration in when configuring fluent NHibernate.

string configFile = "hibernate.cfg.xml";

//setup the normal map configuration
Configuration normalConfig = new Configuration().Configure(configFile);

//setup the fluent map configuration
m => m.FluentMappings

About Sean Biefeld

Hello all, my name is Sean Biefeld. I graduated from Baylor University with a BBA in Management Information Systems. I am currently working for Headspring . I have been a developing software professionally since 2004. My primary development focus is on HTML, CSS, JavaScript and C#. This blog is a forum for me to post my experiences, ideas, rants, and thoughts as I traverse the mountain of life.
This entry was posted in configuration, Fluent NHibernate, infrastructure, Nhibernate. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • perfect, this is what I was looking for a long time … you saved my day by sharing …

  • ZblbkM yderaxajfxdf, [url=]nrqbaxbbuycx[/url], [link=]hjmagpdqleta[/link],

  • Matt

    Thanks a lot!

  • N.K

    I keep getting “An exception occurred during configuration of persistence layer.” when I use this. Any ideas?