8
votes

Ok since my of my issues have been resolved,I was flying through the code, until now: I've now run into one I cant even find anything on Google for it. Here's the text of the error:

Error 3004: Problem in mapping

fragments starting at line 937:No mapping specified for properties StoreItem.ItemPrice in Set StoreItems. An Entity with Key (PK) will not round-trip when: Entity is type [psychoco_GodsCreationTaxidermyModel.StoreItem] F:\Projects\GodsCreationTaxidermySVN\GodsCreationTaxidermy.Data\GCTEntities.edmx 938 945 GodsCreationTaxidermy.Data

Of you need any code samples let me know

3

3 Answers

9
votes

The error means that your table imported to the model contains additional column ItemPrice which is not mapped to your entity.

1
votes

I ran into the same error, using the database first approach. The cause was that when I added an association through the designer, EF decided to add a synthetic field to my principal, based on whatever key relationship I had defined. If you are doing database first, check if ItemPrice on StoreItem is a real database field, or if EF just decided to generate it for you.

0
votes

Just another cause of this that we came across: say we have two developers, A and B.

  1. Dev A adds columns (say "newcol") to a table (say "mytable") in the database project then updates their model. All builds well, database has mytable.newcol and the model reflects this.
  2. Dev B pulls/syncs but forgets to publish the changes to their local database. The model has mytable.newcol but their local database doesn't.
  3. Dev B then changes the model in some way and updates it from the database, VS sees that mytable.newcol doesn't exist so it becomes unlinked.

  4. Dev B realises their error and publishes the database changes.

  5. Dev B then updates the model from the database again. Now VS sees the mytable.newcol column in the database and creates a mytable.newcol1 (note the suffix) that is linked to the database column, since it already had an unlinked newcol in the model.

    For Dev B, VS then complains that mytable.newcol isn't mapped and fails.

Solution - to fix, remove mytable.newcol from the model, rename mytable.newcol1 to newcol... or revert to where you were and remember to publish the database before updating the model!

Hope this helps someone.