Qui*_*Par 17 nhibernate nhibernate-mapping fluent-nhibernate s#arp-architecture
如何在MappingIntegrationTests中作为测试的一部分生成xml映射文件
我需要手动检查流畅的映射是否与leagcy项目中的映射关联.
Mel*_*igy 19
你可以这样做:
config.Mappings(m =>
{
m.FluentMappings.ExportTo("...file path here...");
m.HbmMappings.ExportTo("...file path here...");
m.AutoMappings.ExportTo("...file path here...");
{
);
Run Code Online (Sandbox Code Playgroud)
我自己不喜欢它.如果我找到更好的方法(如果存在的话),我会更新答案.
请参阅
http://blog.jagregory.com/2009/02/03/fluent-nhibernate-configuring-your-application/
或者如果损坏,请参阅此处
https://github.com/jagregory/fluent-nhibernate/wiki/数据库配置
您可以通过调用ExportTo()方法生成XML映射.
例如:
ISessionFactory sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(connectionString)
)
.Mappings(m => m.FluentMappings.AddFromAssembly(assembly)
.ExportTo(@"C:\your\export\path")
)
.BuildSessionFactory();
Run Code Online (Sandbox Code Playgroud)
请参阅此处获取文档:
http://wiki.fluentnhibernate.org/Fluent_configuration