Generate XML mappings from fluent Nhibernate

You can do something like: config.Mappings(m => { m.FluentMappings.ExportTo(“…file path here…”); m.HbmMappings.ExportTo(“…file path here…”); m.AutoMappings.ExportTo(“…file path here…”); { ); I don’t like it myself. If I find some better way (if such exists at all) I’ll update the answer. See http://blog.jagregory.com/2009/02/03/fluent-nhibernate-configuring-your-application/ Or if broken, see this instead https://github.com/jagregory/fluent-nhibernate/wiki/Database-configuration

NHibernate configuration for uni-directional one-to-many relation

NH3 and above allow to correct save entities in case of uni-directional one-to-many mapping without annoying save null–save–update cycle, if you set both not-null=”true” on <key> and inverse=”false” on <one-to-many> FluentNHibernate code snippet for that: public class MasterMap : ClassMap<Master> { public MasterMap() { Id(x => x.MasterId); Map(x => x.Name); HasMany(x => x.Details) .Not.Inverse() //these … Read more

Binary Blob truncated to 8000 bytes – SQL Server 2008 / varbinary(max)

I too have encountered a similar problem and after much experimentation I noticed that when using Nhibernate to generate my schema to a file the generated column type was always length 8000. Setting setting CustomSqlType to Varbinary(max) as suggested above made no difference, however, this work around in my FluentMapping seemed to do the trick: … Read more

NHibernate – CreateCriteria vs CreateAlias

given these requirements there would be no difference, the generated SQL is the same: for mappings: <?xml version=”1.0″ encoding=”utf-8″ ?> <hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2″> <class name=”Project” table=”Project”> <id name=”Id” type=”Int32″ unsaved-value=”0″> <column name=”Id” sql-type=”int” not-null=”true” unique=”true”/> <generator class=”native” /> </id> <many-to-one name=”Job” column=”FK_JobId” cascade=”save-update” not-null=”true” /> </class> </hibernate-mapping> <?xml version=”1.0″ encoding=”utf-8″ ?> <hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2″> <class name=”Job” table=”Job”> … Read more