Please enable Javascript to correctly display the contents on Dot Net Tricks!

Introduction to Fluent Nhibernate

  Author : Shailendra Chauhan
Updated On : 14 Jul 2012
Total Views : 5,547   
 

Fluent Nhibernate is a great O/RM tool to specify strongly typed mapping in the form of classes on the top of NHibernate framework. Fluent Nhibernate offers a simplified implementation of Nhibernate without using the XML(hbm) mapping files.Fluent NHibernate lets you write mappings in strongly typed C# code.

fluent nhibernate also provides the option for you to do an automapping where the mapping is automaticaly created and managed by fluent nhibernate.Creating Fluent Nhibernate automapping is pretty much straight forward in OneToOne, OneTomany relationship , but when it comes to ManyToMany relationship it is not easy.

Nhibernate Configuration files issues

The most important complains I personally have on NHibernate configuration files are:

  1. It is error prone.

  2. Errors in configuration file can be hard to trace.

  3. It is not refactoring friendly.

Fluent NHibernate Tools

  1. Auto mapping

    Fluent NHibernate automatically mapping all your entities based on a set of conventions.By using the auto mappings, you can map your entire domain with very little code, and certainly no XML.

  2. Persistence specification testing

    It provides a round-trip testing for your entities, without ever having to write a line of code. You can quickly test your mappings using the PersistenceSpecification class.

  3. Fluent configuration

    Fluent NHibernate provides an API to configure NHibernate for use with your application

  4. Database configuration

    Fluent NHibernate provides an API for configuring your database, this can be used in combination with the fluent configuration or on it's own.

Installing Fluent NHibernate

Fluent NHibernate is an open source project (OSS). Thus, the code and/or the binaries are freely available and can be downloaded from Github. Before you can start coding, you must first download Fluent NHibernate libraries that can be found here: http://fluentnhibernate.org/ .Unzip downloaded file and extract it into a folder of your choice.

Now start Visual Studio and create new web application project. Now you need to add references of Fluent NHibernate dll to your project. Right click on the References in your solution explorer and select Add Reference. Now browse the directory where you have extracted your Fluent NHibernate libraries and reference the following dll files:

  1. FluentNhibernate.dll

  2. NHibernate.dll

  3. NHibernate.ByteCode.Castle

Now you can continue to work on your web application with fluent nhibernate mapping to the database using strongly typed C# classes.

YOU MIGHT LIKE
Free Interview Books
 
COMMENTS (0)
14 DEC
ASP.NET MVC with AngularJS Development (online)

MON-FRI 07:30 AM- 09:00 AM IST

Know More
5 DEC
AngularJS Development (online)

Mon - Fri     6:30 AM-7:30 AM IST

3 DEC
AngularJS Development (offline)

SAT,SUN     11:00 AM-12:30 PM IST

3 DEC
MEAN Stack Development (offline)

Sat, Sun     (09:30 AM-11:00 AM IST)

26 NOV
ASP.NET MVC with AngularJS Development (offline)

(SAT,SUN)     03:30 PM-05:00 PM IST

24 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     09:30 PM-11:00 PM IST

12 NOV
ASP.NET MVC with AngularJS Development (offline)

SAT,SUN     08:00 AM-09:30 AM

3 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     07:30 AM-09:00 AM IST

25 OCT
.NET Development (offline)

Mon-Fri     9:00 AM-11:00 AM IST

BROWSE BY CATEGORY
 
RECENT ARTICLES
SUBSCRIBE TO LATEST NEWS
 
LIKE US ON FACEBOOK
 

Professional Speaks

+