Koen
Koen

Reputation: 2571

EF Database First - Mapping-error 3025

New to EF and trying something out with "Database first".

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

I have in my db 3 tables:

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

The table PurchaseUsers is to know which participant(s) is(are) using a purchase.

At first I didn't had the PK on that table but then I got the following error when trying to save a Purchase. After googling a bit I found out that I had to add a PK to avoid this error.

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.

But adding the PK created the mapping-error and I just can't figure out how to solve this or create a mapping. The table PurchaseUsers itself isn't visible in my .edmx model, but it's listed in the Store in the Model Browser.

Thanks.

UPDATE

Changed the name of a column in the database today. "Update model from database" added the new columnname to the table in the model, but did not remove the old one. Had to start from scratch once again. Looks like the update-function is not working very well.

Upvotes: 1

Views: 1185

Answers (1)

Pawel
Pawel

Reputation: 31610

This is weird. Updating the model from the database should make the model and the database to by in-sync. Try deleting and recreating the model from scratch.

Upvotes: 1

Related Questions