Configuring NHibernate with App.config or Web.config
Another common method for configuring NHibernate uses a .NET configuration file. In this recipe, we will show you how to configure NHibernate using App.config
or Web.config
files, to provide an identical configuration to the previous recipe.
Getting ready
- Complete the steps in the Installing NHibernate recipe.
- Add a console application project named
ConfigByAppConfig
to your solution. - Set it as the Startup project for your solution.
- Install NHibernate to the
ConfigByAppConfig
project using the NuGet Package Manager Console. - In
ConfigByAppConfig
, add a reference to theEg.Core
project. - Add an
App.config
file to your project.
How to do it…
- Open the
App.config
file. - Declare a section for the NHibernate configuration, ...
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.