public static HbmMapping Generate() { //Conventions var mapper = new ConventionModelMapper(); var baseEntity = typeof (EntityBase); mapper.BeforeMapProperty += (ispector, member, customizer) => customizer.Length(40); mapper.BeforeMapManyToOne += (insp, prop, map) => map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id"); mapper.BeforeMapManyToOne += (insp, prop, map) => map.Cascade(Cascade.Persist); mapper.BeforeMapBag += (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id")); mapper.BeforeMapSet += (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id")); mapper.IsEntity((t, d) => baseEntity.IsAssignableFrom(t) && baseEntity != t); mapper.IsRootEntity((t, d) => t.BaseType == baseEntity); mapper.IsSet(IsSetFieldType); Customize(mapper); HbmMapping mappings = mapper.CompileMappingFor(new[] { typeof (Customization), typeof (Order), typeof (Payment), typeof (OrderItem), typeof (Product) }); return mappings; }