1

EF 新手并尝试使用“数据库优先”进行尝试。

Error 3025: ... :Must specify mapping for all key properties
                    (PurchaseUsers.PurchaseUsersId) of table PurchaseUsers.

我在我的 db 3 表中有:

Purchases       Participants        PurchaseUsers
PurchaseId      ParticipantId       PurchaseUsersId
...             ...                 PurchaseId
                                    ParticipantID

该表PurchaseUsers用于了解哪些参与者正在使用购买。

起初我在该表上没有 PK,但在尝试保存Purchase. 谷歌搜索了一下后,我发现我必须添加一个 PK 以避免这个错误。

Unable to update the EntitySet 'PurchaseUsers' because it has a DefiningQuery 
   and no <InsertFunction> element exists in the <ModificationFunctionMapping> element 
   to support the current operation.

但是添加 PK 创建了映射错误,我只是不知道如何解决这个问题或创建映射。该表PurchaseUsers本身在我的 .edmx 模型中不可见,但它在模型浏览器的 Store 中列出。

谢谢。

更新

今天更改了数据库中列的名称。“从数据库更新模型”将新的列名添加到模型中的表中,但没有删除旧的列名。不得不再次从头开始。看起来更新功能不是很好。

4

1 回答 1

1

这很奇怪。从数据库更新模型应该使模型和数据库同步。尝试从头开始删除并重新创建模型。

于 2012-02-15T17:03:07.710 回答