Search code examples
.netdatabasenhibernatefluent-nhibernatenhibernate-mapping

FluentNhibernate, add mappings from multiple assemblies


I've tried to add mapping classes manually, by using multiple .Mappings extension calls, but it seems only to include the last one. So how do I add several selected class maps, or multiple assemblies?

My fluent configuration looks typically like this:

 Return Fluently.Configure() _
                .Database(SQLiteConfiguration.Standard.ConnectionString(connectionString) _
                .Cache(Function(c) c.UseQueryCache())) _
            .Mappings(Function(m) m.FluentMappings.AddFromAssemblyOf(Of AccountMap)() _
                .Conventions.Add(FluentNHibernate.Conventions.Helpers.DefaultLazy.Never())) _
            .ExposeConfiguration(Function(c) InlineAssignHelper(cfg, c)) _
            .BuildSessionFactory()

Solution

  • Just specify all of your assemblies.

    m.FluentMappings
        .AddFromAssemblyOf(Of AccountMap)()
        .AddFromAssemblyOf(Of SomeOtherMap)();