2011-01-27 133 views
1

我想知道是否有可能映射米:在EF4型號N在數據庫關係的兩倍。映射一個M:N關係兩次

考慮這個數據庫模型:

http://andarki.dk/stackoverflow/db.png

這是一個標準的M:N關係的公司和用戶之間。 如果字段works_at.is_locked_out在模型生成過程中會忽略它產生一個很好的*爲* EF的關係:

http://andarki.dk/stackoverflow/pretty.png

如果我能works_at.is_locked_out它看起來更像原來的DB模式:

http://andarki.dk/stackoverflow/detailed.png

是否可以同時兼得的關係? 對於某些查詢works_at.is_locked_out是沒有必要的,具有直接的聯繫使得它更容易在這些情況下查詢。 當我添加這兩種關係我得到的錯誤

Problem in mapping fragments starting at lines 23, 30:Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns. 
TestModel.edml 

以任何方式這是可能的,或者是它的我試圖讓我的蛋糕,吃它太的情況下?

回答

0

都在同一時間是不可能的,因爲你有你出現的錯誤看看。 This article by Julie Lerman將解釋很多,如果不是全部的話。我認爲你應該去替代2,因爲你說並不總是必要的,但有時(或在不久的將來),它是。我猜這個領域沒有任何目的......)祝你好運!