我正在尝试让Fluent nHibernate生成映射,以便我可以查看文件和sql。
我的代码基于这篇文章以及我可以从文档中收集的内容。
Fluent mapping - entities and classmaps in different assemblies
我正在使用git的最新代码。
这是我的配置代码:
Configuration cfg = new Configuration();
var ft = Fluently.Configure(cfg);
//DbConnection by fluent
ft.Database
(
MsSqlConfiguration
.MsSql2008
.ConnectionString("……")
.ShowSql()
.UseReflectionOptimizer()
);
//get mapping files.
ft.Mappings(m =>
{
//set up the mapping locations
m.FluentMappings.AddFromAssemblyOf<Entity>()
.ExportTo(@"C:\temp");
m.Apply(cfg);
});
我也尝试过:
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration
.MsSql2008
.ShowSql()
.ConnectionString(“……"))
.Mappings(p => p.FluentMappings
.AddFromAssemblyOf<Entity>()
.ExportTo(@"c:\temp\"))
.BuildSessionFactory();
我已验证连接字符串是否正确。
问题是ExportTo文件夹中没有显示映射文件,输出窗口或日志文件中也没有显示sql代码。也不会产生任何错误或异常。
我不知道从哪里开始。
提前谢谢。
瑞克
答案 0 :(得分:0)
我认为你必须实际启动一些对象来写出地图。如果我没记错的话,这不是在配置时完成的。