I'm trying out the automapping capability of Fluent NHibernate, and the same code that worked with explicit ClassMap
configurations is failing when building the SessionFactory
when I try to move it to automapping.
Here's the code:
public static ISessionFactory GetSessionFactory()
{
if (_sessionFactory == null)
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("DB")))
// It works with the following:
// .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Customer>())
// It fails with this:
.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Customer>()))
.BuildSessionFactory();
return _sessionFactory;
}
The error I get is:
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
I get Count = 0
for PotentialReasons
and the inner exception is the same as above.
The stacktrace refers to:
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH-v1.x-nh3\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 113
It seems like I've tried everything to get it to work, and the closest I came was to have the initialization work only to get a Could not find persister for...
error when I tried to use the session, and I don't even remember how I was able to get that to happen.
I'm using the build #694 with NHibernate 3.0, SQL 2008 database. Any ideas what I'm doing wrong?
CustomType(typeof(MyEnum))
but I'll have to see how that's possible when automapping... – Josh Anderson