流畅的NHibernate ExportSchema没有连接字符串

Vin*_*nce 5 database nhibernate configuration fluent schemaexport

我想生成一个数据库脚本,而没有声明实际的数据库连接字符串.

为了做到这一点,我现在使用NHibernate ExportSchema基于用Fluent NHibernate生成的NHibernate配置(在我的ISessionFactory创建方法期间):

FluentConfiguration configuration = Fluently.Configure();               
//Mapping conf ...
configuration.Database(fluentDatabaseProvider);
this.nhibernateConfiguration = configuration.BuildConfiguration();
returnSF = configuration.BuildSessionFactory();     

//Later
new SchemaExport(this.nhibernateConfiguration)              
                .SetOutputFile(filePath)
                .Execute(false, false, false);      
Run Code Online (Sandbox Code Playgroud)

fluentDatabaseProvider是一个FluentNHibernate IPersistenceConfigurer,需要获取正确的sql方言来创建数据库.

使用现有数据库创建工厂时,一切正常.但我想要做的是在选定的数据库引擎上创建一个NHibernate配置对象,而不需要在场景后面有真正的数据库...而且我无法做到这一点.

如果有人有一些想法.

lon*_*day 0

尝试使用:

.Create(false, false);
Run Code Online (Sandbox Code Playgroud)

代替

.Execute(false, false, false); 
Run Code Online (Sandbox Code Playgroud)

不要将连接字符串属性添加到 IPersistenceConfigurer (fluentDatabaseProvider)。