protected Database(IPersistenceConfigurer pcfg, IDomainDefinition mappings) { var clsmaps = new DomainType[]{DomainType.Class,DomainType.ClassWithoutBaseClass}; var cfg = Fluently.Configure() .Database(pcfg) .Mappings(m => { var am1 = AutoMap.Assembly(mappings.DomainAssembly) .Where(t => clsmaps.Contains(mappings.GetDomainType(t))) .Setup(c => { c.IsComponentType = t => typeof(MyText).IsAssignableFrom(t) || mappings.GetDomainType(t) == DomainType.Component; c.IsConcreteBaseType = t => IsConcreteBaseType(t) || mappings.GetDomainType(t) == DomainType.ClassWithoutBaseClass; c.GetComponentColumnPrefix = pi => { return pi.Name; }; }); foreach (var mod in mappings.RegisteredModules) mod.Map(mappings, am1); am1.GetType().GetMethod("UseOverridesFromAssemblyOf").MakeGenericMethod(mappings.GetType()).Invoke(am1, null); am1.Alterations(a => { a.GetType().GetMethod("AddFromAssemblyOf").MakeGenericMethod(mappings.GetType()).Invoke(a, null); }); m.AutoMappings.Add(am1); if (mappings.WriteHbmFilesToPath != null) { foreach (var v in m.AutoMappings) { v.BuildMappings(); v.WriteMappingsTo(mappings.WriteHbmFilesToPath); } } }).ExposeConfiguration(c => { foreach (var mod in mappings.RegisteredModules) mod.Configure(c); }).BuildConfiguration(); SessionFactory = cfg.BuildSessionFactory(); CreateDB = () => { LocalSession = LocalSession??SessionFactory.OpenSession(); new SchemaExport(cfg).Execute(false, true, false, LocalSession.Connection, null); }; UpdateDB = () => { new SchemaUpdate(cfg).Execute(false, true); }; DropDB = () => { new SchemaExport(cfg).Drop(true, true); }; }