1
我有兩個表,用戶和地址。用戶表具有映射到地址表的主鍵的字段。該字段可以爲空。如何在實體框架中映射0..1到1的關係3
簡明英語中,地址獨立於其他對象存在。用戶可能與一個地址相關聯。在數據庫中,我將此設置爲外鍵關係。
我正試圖在實體框架中映射這種關係。我在下面的代碼上得到錯誤:
<Association Name="fk_UserAddress">
<End Role="User" Type="GenesisEntityModel.Store.User" Multiplicity="1"/>
<End Role="Address" Type="GenesisEntityModel.Store.Address" Multiplicity="0..1" />
<ReferentialConstraint>
<Principal Role="Address">
<PropertyRef Name="addressId"/>
</Principal>
<Dependent Role="User">
<PropertyRef Name="addressId"/>
</Dependent>
</ReferentialConstraint>
</Association>
它給出了「多重性的下界必須爲0」的錯誤。
如果有人能解釋錯誤並解決它的最佳方法,我將不勝感激。
感謝您的任何幫助。
從我目前所知的情況看,地址表必須具有多重*。思考它,這實際上是有道理的。其他人有其他信息嗎? – Sako73 2010-04-08 14:38:46