views:

27

answers:

1

Hello,

I am trying to get Fluent nHibernate to generate mappings so I can take a look at the files and the sql.

My code is based on this post and on what I can glean from the documentation.

http://stackoverflow.com/questions/1375146/fluent-mapping-entities-and-classmaps-in-different-assemblies

I am using the latest code from git.

Here’s my config code:

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

I also tried:

        var sessionFactory = Fluently.Configure()
            .Database(MsSqlConfiguration
                .MsSql2008
                .ShowSql()
                .ConnectionString(“……"))

             .Mappings(p => p.FluentMappings
                .AddFromAssemblyOf<Entity>()
                .ExportTo(@"c:\temp\"))

            .BuildSessionFactory();

I have verified that the connection string is correct.

The issue is that no mapping files show up in the ExportTo folder and no sql code shows up in the output window or in the log file. No errors or exceptions are generated either.

I have no idea where to go from here.

Thank you in advance.

Rick

A: 

I think you have to actually spin up some objects to get the maps written out. If I remember correctly, this is not done at config time.

Sky Sanders