1

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.

Koen
  • 2,501
  • 1
  • 32
  • 43
  • Have you updated the model (in the designer) after you added the primary key in the database? – Pawel Feb 14 '12 at 05:19
  • @Pawel Yes, I did. And at that moment I get the 3025 error. Also the relations are set on db-level. In my model there's a mazny-to-many relation between tables Participants and Purchases. And I guess that's where things go wrong because the bridge-table is not in the model to link those 2 tables. – Koen Feb 14 '12 at 07:25
  • This is weird. Have you tried deleting the model entirely and creating from scratch? If this sill does not work for you - are you able to post a minimal repro? – Pawel Feb 14 '12 at 21:16
  • @Pawel This is indeed weird. Starting from scratch did the trick, although one should think that "Update model from database" should have worked also. Anyway, thanks a lot. Now I can continue goofing around some more :-) If you want, you can post this as an answer so this question can be closed. – Koen Feb 14 '12 at 22:18

1 Answers1

1

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.

Pawel
  • 31,342
  • 4
  • 73
  • 104