作者:北京赛车外围投注网 | 来源:互联网 | 2023-10-13 13:22
Iwanttogenerateadatabasescriptwithouthavinganactualdatabaseconnectionstringdeclared.我
I want to generate a database script without having an actual database connection string declared.
我想生成一个数据库脚本,而没有声明实际的数据库连接字符串。
To do this for now i use NHibernate ExportSchema bases on a NHibernate configuration generated with Fluent NHibernate this way (during my ISessionFactory creation method):
为了实现这一点,我使用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);
fluentDatabaseProvider is a FluentNHibernate IPersistenceConfigurer which is needed to get proper sql dialect for database creation.
fluentDatabaseProvider是一个FluentNHibernate IPersistenceConfigurer,需要获取正确的sql方言来创建数据库。
When factory is created with an existing database, everything works fine. But what i want to do is to create an NHibernate Configuration object on a selected database engine without a real database behind the scene... And i don't manage to do this.
使用现有数据库创建工厂时,一切正常。但我想要做的是在选定的数据库引擎上创建一个NHibernate配置对象,而不需要在场景后面有真正的数据库...而且我无法做到这一点。
If anybody has some idea.
如果有人有一些想法。
2 个解决方案