Fluent NHibernate: Seeing the mapping files generated
We’ve been fiddling around with Fluent NHibernate a bit over the last couple of days and one of the things that we wanted to do was output the NHibernate mapping files being generated so we could see if they were as expected.
I couldn’t figure out how to do it but thanks to the help of James Gregory, Andrew Bullock and Matthew Erbs on twitter this is the code that you need in order to do that:
Fluently .Configure() .Database(MsSqlConfiguration.MsSql2000.ConnectionString("connection string")) .Mappings(m => m.FluentMappings.ExportTo("c:\\directory-to-output-files-to")) .BuildSessionFactory();
The 4th line is the important one here and we can choose which directory the mappings files get outputted to and then check that everything is getting setup as we’d expect.