5

実際のデータベース接続文字列を宣言せずにデータベーススクリプトを生成したい。

今のところこれを行うには、次のようにFluent NHibernateで生成されたNHibernate構成に基づいてNHibernateExportSchemaを使用します(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);      

fluentDatabaseProviderは、データベース作成用の適切なSQLダイアレクトを取得するために必要なFluentNHibernateIPersistenceConfigurerです。

工場が既存のデータベースで作成される場合、すべてが正常に機能します。しかし、私がやりたいのは、実際のデータベースをバックグラウンドで使用せずに、選択したデータベースエンジンでNHibernate構成オブジェクトを作成することです...そして私はこれを行うことができません。

誰かが何か考えを持っているなら。

4

2 に答える 2

1

これは私が使用したものです。私の間違いは、データベースに接続しようとする BuildSessionFactory を呼び出すことでした:

        var config = Fluently.Configure()
          .Database(MsSqlConfiguration.MsSql2008)
          .Mappings(m =>
            m.FluentMappings.AddFromAssemblyOf<SessionManager>());

        new SchemaExport(config.BuildConfiguration())
                .SetOutputFile(filedestination)
                .Create(false, false);
于 2012-08-16T12:26:41.040 に答える
0

Try using:

.Create(false, false);

inplace of

.Execute(false, false, false); 

Do not add the connectionstring property to the IPersistenceConfigurer (fluentDatabaseProvider).

于 2011-04-06T20:29:11.770 に答える