Generate XML mappings from fluent Nhibernate

Viewed 7874

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 the leagcy project.

3 Answers

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

Related