I had no problems with this.
public static ISessionFactory Create(string connectionString) {
return FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.Is(connectionString))
.AdoNetBatchSize(50)
.FormatSql()
.UseReflectionOptimizer())
.Cache(c => c
.ProviderClass<NHibernate.Caches.SysCache2.SysCacheProvider>()
.UseQueryCache()
.UseSecondLevelCache()
.UseMinimalPuts())
.ExposeConfiguration(config => {
new NHibernate.Tool.hbm2ddl.SchemaExport(config)
.Drop( false, true);
})
.ExposeConfiguration(config => {
new NHibernate.Tool.hbm2ddl.SchemaExport(config)
.Create( true, true);
})
.Mappings(m => {
m.FluentMappings.Conventions.Setup(x => {
x.AddFromAssemblyOf<Mappings.AspectMap>();
x.Add(FluentNHibernate.Conventions.Helpers.AutoImport.Never());
});
m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly());
})
.BuildSessionFactory();
}
source
share