时间:2010-07-24 17:47:37

标签: nhibernate fluent-nhibernate s#arp-architecture hbm

3 个答案:

答案 0 :(得分:4)

答案 1 :(得分:0)

http://wiki.fluentnhibernate.org/Fluent_configuration#Exporting_mappings

在Mappings调用中,您可以执行以下操作:

.Mappings(m =>
{
  m.FluentMappings
    .AddFromAssemblyOf<YourEntity>()
    .ExportTo(@"C:\your\export\path");

  m.AutoMappings
    .Add(/* ... */)
    .ExportTo(@"C:\your\export\path");
})

答案 2 :(得分:0)

事实证明只有在你不使用自动化时才有效。如果您使用自动化,这是解决方案:

public void CanGenerateMappingFiles() 
{ 
    DirectoryInfo directoryInfo = new DirectoryInfo("../../../../db/mappings"); 

    if (!directoryInfo.Exists) 
        directoryInfo.Create(); 

    Configuration cfg = new Configuration().Configure();  
    var autoPersistenceodel = new AutoPersistenceModelGenerator().Generate(); 

    autoPersistenceodel.Configure(cfg); 
    autoPersistenceodel.AddMappingsFromAssembly(Assembly.Load("TrackerI9.Data")); 
    autoPersistenceodel.WriteMappingsTo(directoryInfo.FullName); 
} 

您必须确保您的配置设置正确并且您为目录选择了适当的位置,否则这应该有效。它确实适合我。