I thought this would be pretty simple, but it is proving a bit more frustrating than I anticipated.
Given a structure similar to this ...
class Template { public virtual int Id { get; set; } public virtual Attached Attached { get; set; } } class Attached { public virtual int Id { get; set; } public virtual Template Template { get; set; } } I want the table structure to look like this.
Table - Template
Id
Table - Attached
Id - TemplateId
So I set up my mapping ...
class TemplateMap : ClassMap<Template> { TemplateMap(){ HasOne(x => x.Attached).Cascade.All(); Table("Templates"); } } class AttachedMap : ClassMap<Attached> { AttachedMap(){ References(x => x.Template).Cascade.All().Column("TemplateId"); Table("Attached"); } } then I create a new Template
var tmpl = new Template { Attached = new Attached { // ... } }; session.SaveOrUpdate(tmpl); transaction.Commit(); But my TemplateId in the Attached table still comes out Null. Any ideas?