When we configure the Nhibernate session factory, with fluentnhibernate, we can add the mapping files using AddFromAssembly, AddFromAssemblyOf, or Add. The first two scan the assembly for the ClassMaps. Probably there is no considerable difference, but which one is the best in terms of reducing the sessionfactory creation time? Maybe «Add» because we explicitly indicate the Classes, so there is no need for assembly scanning?
+1
A:
You should profile your application and see what is taking the most amount of time. The AddXXX
methods from Fluent NHibernate scan the assemblies for ClassMaps, but even after that has occurred NHibernate itself can spend a significant amount of time building the session factory. Check that it is actually the assembly scanning that's causing you trouble, and not NHibernate itself.
If it really is the assembly scanning, then just using Add
will circumvent that.
James Gregory
2010-01-12 11:01:18