Skip to content

Instantly share code, notes, and snippets.

@brianium
Created July 3, 2012 18:06
Show Gist options
  • Save brianium/3041445 to your computer and use it in GitHub Desktop.
Save brianium/3041445 to your computer and use it in GitHub Desktop.
NHibernate fluent out of the box
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString("server=.\\SQLEXPRESS;database=NH3BeginnersGuide;Integrated Security=SSPI"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactoryProvider>())
.ExposeConfiguration((cfg) => {
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(false, true);
schemaExport.Create(false,true);
})
.BuildConfiguration()
.CurrentSessionContext<ThreadStaticSessionContext>()
.BuildSessionFactory();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment