Skip to content

Commit aea486a

Browse files
owerkopchester89
authored andcommitted
Fixed RelationshipKeyPairingVisitor - all many-to-one relations with two ends will use the same (single) foreign column name at children table.
Before that fix such relations were mapped this way: "one" side used childtype.Name+"_id", "many" side used referenceToParentProperty.Name+"_id". It seemed to work just because usually referenceToParent property name is equal to parent's type name.
1 parent d705405 commit aea486a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/FluentNHibernate/Visitors/RelationshipKeyPairingVisitor.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ public override void ProcessManyToOne(ManyToOneMapping thisSide)
1414
// other side is always going to be a collection for a many-to-one mapping
1515
var otherSide = (CollectionMapping)thisSide.OtherSide;
1616

17-
if (thisSide.ContainingEntityType == otherSide.ContainingEntityType)
18-
{
19-
// special case for self-referential relationships
20-
otherSide.Key.MakeColumnsEmpty(Layer.Defaults);
21-
thisSide.Columns.Each(x => otherSide.Key.AddColumn(Layer.Defaults, x.Clone()));
22-
}
17+
otherSide.Key.MakeColumnsEmpty(Layer.Defaults);
18+
thisSide.Columns.Each(x => otherSide.Key.AddColumn(Layer.Defaults, x.Clone()));
2319
}
2420
}
2521
}

0 commit comments

Comments
 (0)