In this blog, I am going to cover few issues which you generally face while using Fluent NHibernate in different scenarios.

First issue occurs when you are working on some platform based application, where you don’t want your configuration related code to be changed at any point of time. Moreover you wanted your code to be hidden and non-accessible, but due to the current architecture of fluent nhibernate there is not much options left.

Second issue is generally faced in case of big and growing applications. In a growing application new projects keep on adding in the solution and you have to support entity creation of these newly added projects. If the project is big, code maintenance also becomes a tedious job.

Create custom configuration in the newly created project and dynamically load assemblies from custom configuration to fluent nhibernate configuration.

I like to choose the second option.

Let’s understand in details how we will load assemblies dynamically using custom configuration. To load assemblies dynamically you have to create a custom configuration section in your newly added project’s config file.

This custom configuration section can be added in any project in the solution, to load the assemblies dynamically without any code change. Using this approach, we will resolve our both issues. This solution will make our application dynamic as well as provide clean and easily maintainable code.