public void ApplyMapping(ConventionModelMapper mapper) { mapper.Class <TicketRelationship>(map => { map.ManyToOne(x => x.PrimaryTicket, propMap => { propMap.Column(nameFormatter.GetForeignKeyColumnName(Reflect.Property <TicketRelationship>(x => x.PrimaryTicket))); propMap.ForeignKey(nameFormatter.GetForeignKeyConstraintName(Reflect.Property <TicketRelationship>(x => x.PrimaryTicket), typeof(TicketRelationship))); propMap.Index(nameFormatter.GetIndexName(typeof(TicketRelationship), Reflect.Property <TicketRelationship>(x => x.PrimaryTicket))); propMap.Cascade(Cascade.Persist); }); map.ManyToOne(x => x.SecondaryTicket, propMap => { propMap.Column(nameFormatter.GetForeignKeyColumnName(Reflect.Property <TicketRelationship>(x => x.SecondaryTicket))); propMap.ForeignKey(nameFormatter.GetForeignKeyConstraintName(Reflect.Property <TicketRelationship>(x => x.SecondaryTicket), typeof(TicketRelationship))); propMap.Index(nameFormatter.GetIndexName(typeof(TicketRelationship), Reflect.Property <TicketRelationship>(x => x.SecondaryTicket))); propMap.Cascade(Cascade.Persist); }); }); }
public void ApplyMapping(ConventionModelMapper mapper) { mapper.BeforeMapManyToOne += (modelInspector, member, propertyCustomizer) => { var parentType = member.LocalMember.GetPropertyOrFieldType(); var childType = member.LocalMember.ReflectedType; propertyCustomizer.Column(formatter.GetIdentityColumnName(parentType)); propertyCustomizer.ForeignKey(formatter.GetForeignKeyConstraintName(parentType, childType)); propertyCustomizer.Index(formatter.GetIndexName(childType, parentType)); propertyCustomizer.Cascade(Cascade.Persist); }; }