One to Many mapping with an intermediate table

前端 未结 2 1213
不知归路
不知归路 2021-01-15 23:06

I thought I had this one pegged by mapping the intermediary table as a HasMany and between intermediary and child as HasOne, however HasOne expects to share a key. (No Inver

2条回答
  •  清歌不尽
    2021-01-15 23:50

    map it as normal references

    public class CustomerAddressMap : ClassMap
    {
        public CustomerAddressMap()
        {
            Table("CustomerAddress");
    
            Id(x => x.CustomerAddressId);
            Map(x => x.FromDate).Not.Nullable();
            Map(x => x.ToDate);
            References(x => x.Customer, "CustomerId");
            References(x => x.Address, "AddressId");
        }
    }
    

提交回复
热议问题