Automatically create the schema in PostgreSQL with Fluent NHibernate -


how create database schema automatically in fluent nhibernate? configuration is:

  public static isessionfactory createdatabase() {   switch (4) {     case 4: // postgress     _sessionfactory = fluently.configure()       .database(postgresqlconfiguration.postgresql82.connectionstring(connectionstring))       .exposeconfiguration(c => {         c.setproperty("cache.use_second_level_cache", "false");         c.setproperty("cache.use_query_cache", "false");       })       .exposeconfiguration(schemametadataupdater.quotetableandcolumns)       .exposeconfiguration(x => new schemaupdate(x).execute(false, true))       .mappings(m => m.fluentmappings.addfromassemblyof<pessoa>())       .currentsessioncontext<websessioncontext>()       .buildconfiguration()       .buildsessionfactory();     break;   }   _sessionfactory.dispose();   return _sessionfactory; } 

currently have method creates using npgsqlcommand.

to create schema nhibernate, use schemaexport class:

configuration cfg = ....; new schemaexport(cfg).create(false, true); 

more details in nhibernate reference, section 20.1.2. running tool, , preceding section.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -