One of the most common ways to configure NHibernate is to put the configuration into the Web.config
or App.config
file of the application. Other settings for your application are already stored here such as application settings in the <appSettings>
block and database connection strings in the <connectionStrings>
block.
By placing our configuration information in the Web.config
, we can consolidate all of our configuration information together and take advantage of the available protections on that file such as cryptography and file separation, which we will talk about a little later.
In order to take advantage of mapping in the Web.config
(or App.config
) file, we need to add a configuration section handler declaration at the top of our configuration file, just like the one we added for log4net in the previous chapter. Inside the <configSections>
element, we need to add a new <section>
handler element with a name
property of hibernate-configuration...