這是自動映射。
.Override<Address>(mapping => mapping.HasOne(address => caddress.AddressA).Cascade.All().LazyLoad())
.Override<Address>(mapping => mapping.HasOne(address => caddress.AddressB).Cascade.All().LazyLoad())
.Override<AddressA>(mapping => mapping.Id(x => x.Id).GeneratedBy.Foreign("Address"))
.Override<AddressB>(mapping => mapping.Id(x => x.Id).GeneratedBy.Foreign("Address"))
.Override<AddressA>(
mapping => mapping.HasOne(
Reveal.Member<AddressA, Address>("Address")).Constrained().ForeignKey().LazyLoad())
.Override<AddressB>(
mapping => mapping.HasOne(
Reveal.Member<AddressB, Address>("Address")).Constrained().ForeignKey().LazyLoad())
所有這些表有同樣鍵:身份證
+----------+
| Address |
+----------+
| Id | PK
+----------+
+----------+
| AccountA |
+---------+
| Id | PK
+----------+
+----------+
| AccountB |
+---------+
| Id | PK
+----------+