Configuring NHibernate with Fluent NHibernate

The third-party Fluent NHibernate library has its own syntax to configure NHibernate. In this recipe, we'll show you how to configure NHibernate using this syntax.

Getting ready

  1. Complete the steps in Installing NHibernate recipe.
  2. Add a console application project to your solution called ConfigByFNH.
  3. Set it as the Startup project for your solution.
  4. Install NHibernate to the ConfigByFNH project using NuGet Package Manager Console.
  5. Install the package FluentNHibernate to ConfigByFNH project using NuGet Package Manager Console.
  6. In ConfigByFNH, add a reference to the Eg.Core project.

How to do it…

  1. Add an App.config file with this configuration:
    <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> ...

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.