Created
July 3, 2012 18:06
-
-
Save brianium/3041445 to your computer and use it in GitHub Desktop.
NHibernate fluent out of the box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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