In one of my ASP.Net MVC projects xml file was used for NH configuration (hibernate.cfg.xml) because of historical reasons. It was annoying because settings were stored in several files: web.config and hibernate.cfg.xml. It was double annoying because Fluen NHibernate contains API for configuration (in my project Fluent NH was used as well). But as it often happens I had no time to fix it. Configuration code looked like this:
And configuration file is the following:
Recently I had time to fix it and publish it here for quick reference:
Here we read connection string from web.config and do the rest actions via Fluent configuration API. After that hibernate.cfg.xml can be finally removed from the project.