如何在 Fluent Nhibernate 中自动创建数据库模式?我的配置是:
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;
}
目前有一个使用 NpgsqlCommand 创建的方法。