I would say, that this should not be an issue. What we at the end need - is the Configuration object - provided with both (or even more) mapping 1) from Fluent as well as 2) from Mapping-by-code. Based on these resources:
This could be the configuration:
// standard Fluent configuration
var fluentConfig = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(@"Data Source=.;Database=TheCoolDB;Trusted_Connection=yes;"))
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<MyAwesomeEntityMap>());
// return the NHibernate.Cfg.Configuration
var config = fluentConfig
.BuildConfiguration();
// now Mapping by Code
// firstly the Mapper
var mapper = new NHibernate.Mapping.ByCode.ModelMapper();
mapper.AddMappings(Assembly
.GetAssembly(typeof(IdentityUser)) // here we have to get access to the mapping
.GetExportedTypes());
// finally the mapping just read
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
// extend already existing mapping
config.AddDeserializedMapping(mapping, null);
// the ISessionFactory
var factory = config.BuildSessionFactory();
Extend:
Not sure how to mix the fluent and mapping by code for purposes of inheritance...
But there is even more narrow way how to configure fluently and inject some mapping-by-code parts:
// Let's start with mapping-by-code,
// so firstly create the Mapper
var mapper = new NHibernate.Mapping.ByCode.ModelMapper();
mapper.AddMappings(Assembly
.GetAssembly(typeof(IdentityUser)) // here we have to get access to the mapping
.GetExportedTypes());
// create the mapping
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
// standard Fluent configuration
var fluentConfig = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(@"Data Source=.;Database=TheCoolDB;Trusted_Connection=yes;"))
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<MyAwesomeEntityMap>())
// here we INJECT the HBM mapping
// via call to built in ExposeConfiguration(Action<Configuration> config)
.ExposeConfiguration(c => c.AddDeserializedMapping(mapping, null));
// the ISessionFactory
var factory = fluentConfig
.BuildSessionFactory();