Generate XML mappings from fluent Nhibernate

前端 未结 3 1446
Happy的楠姐
Happy的楠姐 2020-11-30 08:07

How do I generate xml mappings files as part of my tests in MappingIntegrationTests

I need to manually check if the fluent mappings correlate to the mappings in t

3条回答
  •  死守一世寂寞
    2020-11-30 08:20

    You generate XML mappings by calling the ExportTo() method.

    For example:

    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();
    

    See here for documentation:

    http://wiki.fluentnhibernate.org/Fluent_configuration

提交回复
热议问题