Here is my educated guess.
As you suggest, under normal M:N circumstances, MachineProduct would be a "link table" and repeats could be possible.
I think you can "singularize" the relationships...use the ".Unique()".
I think this is barking up the right tree.
public class MachineProductMap : ClassMap<MachineProductNHEntity>
{
public MachineProductMap()
{
Schema("dbo");
Table("MachineProduct");
/* Your surrogate key setup here */
Id(x => x.MachineProductUUID).GeneratedBy.GuidComb().Index("IX_MachineProduct_MachineProductUUID");
References<MachineNHEntity>(x => x.ParentMachine)
.Class(typeof(MachineNHEntity))
.Not.Nullable()
.Unique()
.Column("ParentMachineUUID")
.Index("IX_MachineProduct_ParentMachineUUID")
.Cascade.SaveUpdate()
;
;
References<ProductNHEntity>(x => x.ParentProduct)
.Class(typeof(ProductNHEntity))
.Nullable()
.Unique()
.Column("ParentProductUUID")
.Index("IX_MachineProduct_ParentProductUUID")
.Cascade.SaveUpdate()
;
;
}
}
APPEND:
I think the above works, but you later state you don't want a middle-man entity.
So here is a another attempt using "Join".....
I think you want something like this:
public class Product
{
public virtual int ProductSurrogateKey { get; set; } /* ID */
}
public partial class Machine
{
public virtual Guid? MachineUUID { get; set; }
public virtual Product TheProduct { get; set; }
}
public class MachineMap : ClassMap<Machine>
{
public MachineMap()
{
Table("Machine");
Id(x => x.MachineUUID).GeneratedBy.GuidComb().Index("IX_Machine_MachineUUID");
Join("MachineProductArtificialReferenceMaker", join =>
{
join.KeyColumn("ParentMachineUUID");
join.References(prop => prop.TheProduct);
});
}
}
This creates a table called "MachineProductArtificialReferenceMaker".
This table has a FK to Machine.MachineUUID. (not null)
And a FK to Product.ProductSurrogateKey (nullable)