62

To improve an older project I am forced by the circumstances to use VS 2008 and Framework 3.5 - I have issues with the edmx showing bizarre behavior and not updating the entities as required.

The edmx throws me the above error, but when I go to the respective table and right click it - "Update Model from Database" there is no change, the error is still there.

If I delete the table from the diagram by selecting it and pressing del, then in the Model Browser It disappears from the .Database but when clicking "Update model from Database" I can't see i in the "Add" list, all I can do is "Refresh" the table since I still see it in the refresh list (which should not happen because I deleted it! )

3
  • 1
    check the xml file of your model, it's probably still in there somewhere. Try deleting it manually from that xml file, then try to update again. Take backups tho :)
    – Thousand
    Oct 8, 2012 at 11:05
  • Your sugegstion worked. Please rewrite as answer so I can give credits
    – Amc_rtty
    Oct 8, 2012 at 16:15
  • get the line number from error open xml file go to that line add a scaler property with the name specified in error save ... and rebuild .. May 15, 2013 at 7:25

14 Answers 14

55

I had this issue when I changed a column name from CampaignKey to CampaignCode. After making the DB change, I went to the .edmx designer, right clicked and chose Update Model from Database. Then when I compiled I got the error:

Error 11009: Property CampaignKey is not mapped.

Taking a closer look at my table in the designer showed me that Visual Studio had created the new field CampaignCode as in the DB. But it also had left the old field CampaignKey in there, causing the error as it no longer exists in the DB.

To fix the issue, I right-clicked on the CampaignKey field in my table in the designer and selected Delete.

After that I saved the .edmx, compiled and the error was gone.

2
  • 1
    Yes, this seems to be the case for me too.. Do you know if this is a bug?
    – Narayana
    Nov 10, 2013 at 16:30
  • 6
    Please note, you may need to close and then reopen the designer before this error disappears.
    – Sam Shiles
    Jan 20, 2017 at 15:09
54

Check the xml file of your model, it's probably still in there somewhere. Try deleting it manually from that XML file, then try to update again. Be sure to take backups though.

3
  • 3
    thanks, this was the solution. its pretty bugged, i must delete the entity completely and then remove all its traces from the xml - then add it again, and add the stored procedures again as function imports (when deleting an entity, the function imports that were using get deleted too). thanks
    – Amc_rtty
    Oct 9, 2012 at 9:15
  • I guess this is somewhat a solution. unfortunately, the model also has this property... and when I try to delete the property in the model and try to update, - the update wizard crashes each time. Oct 9, 2014 at 7:43
  • @Amc_rtty I encountered the same, when renaming the database column. As a solution it worked to do the following After the update: (i.e. Column was renamed from BreatedBy to CreatedBy: 1.) Do the update, this will yield in the error you described. In the Modeldesigner, rename CreatedBy to BreatedBy again (Save model) - and re-rename it again to the desired state. (save model) Then the model is properly updated "everywhere". Just updating the xml yielded in the problem, that the query still referenced the "old" column.
    – dognose
    May 9, 2018 at 14:45
3

I have gotten this same error before when column names on tables or views change case. For example, if a view has a column named "OrderID" and then the column name is changed to "OrderId" then it will give the error 'Property "OrderID" is not mapped'. This can be resolved by changing the case back to how it exists in the model.

3

I opened the edmx file in Notepad and deleted the incorrect field. I then updated the model again in the designer

1
  • I didn't want to delete table and add again, so I tried this and it worked. Thnx Nov 1, 2016 at 13:14
2

At times, upgrading a project throws up errors.

Just make sure you have backed up all your data, just-in-case.

When we add entity model into our project, it adds a corresponding connection string to web.config. Now, when you delete the model from project, even then the connection string still resides there in the web.config.

So, take the following steps:

  1. Delete the model
  2. Delete the corresponding connection string from web.config
  3. Now, perform the steps to add the model again from scratch.

Hopefully, it should work.

2
  • 1
    No problem with down vote, but please specify the reason for the down vote. This answer conveys the same thing which the 'Accepted Answer' does.
    – Viral Jain
    Nov 7, 2013 at 3:28
  • 2
    @Daradev, I do not agree, your solution is completely different from the accepted aswer, the accepted answer says to deleted old/changed properties in the edmx (xml) file, and then update again. You want us the delete the model completely, that will probaly work too, but it's defenitly not the same.
    – Michiel
    Dec 11, 2013 at 11:15
2

I know this question was about VS 2008 and 'recovering' a model, but for anyone who finds this like I did when I had the same Error 11009 in VS 2015, I first tried the "Update Model from Database" to no avail, then I finally fixed it by right-clicking the model table in the .edmx design and choosing Table Mapping. I did not have to delete the model. My model is associated with a db table.

1
  • This. There is no need to delete anything. And if the property does not exist you can add it manually through the model browser. Then you will see it in the table mapping.
    – user8760162
    Oct 17, 2018 at 14:14
2

The easiest way I've found to deal with this is to find the model/table with the unmapped property in the edmx. Select it and delete it. Save your edmx and then update it again, adding the model back in from the database. Deleting just the unmapped property didn't work for me.

1

I had the same error when I changed a column name in the database and updated the database from the model. I was unable to find the original name anywhere in the solution. I solved it by simply

  1. deleting the table from the model (right-click on the table, hit delete),
  2. updating the model from the database (right-click on edmx background, select "Update Model From Database", Add changed table).
1

In my case I added a new scalar property named sys_user_id to an existing table in the Designer inside Visual Studio. I didn't update the Model from the Database because that was causing a lot of errors in the designer. I just wanted to map a single column that was added to a given table on the database side.

The problem is that after doing this I started getting the following exception:

  • InnerException {"\r\nModels.ShardData.msl(352,10) : error 3004: Problem in mapping fragments starting at line 352: No mapping specified for properties table_name.sys_user_id in Set table_name.\r\nAn Entity with Key (PK) will not round-trip when:\r\n Entity is type [ShardDB.table_name]\r\n"} System.Exception {System.Data.Entity.Core.MappingException}

In Visual Studio what was being shown in the Error List window was: Error 11009: Property ' ' is not mapped

What I did to fix this was the following:

  1. Opened the .edmx file in Visual Studio Code;
  2. Searched for the offending table_name;
  3. Added the missing mappings where appropriate.

It was missing the mappings in 2 places:

<EntityType Name="table_name">
    <Key>
        <PropertyRef Name="user_id" />
    </Key>
    <Property Name="user_id" Type="int" Nullable="false" />
    <Property Name="tenant_id" Type="int" />
    ... ALL OTHER COLUMNS HERE ...
    <Property Name="sys_user_id" Type="int" Nullable="true" /> <= WAS MISSING THIS AND SO I HAD TO ADD IT BY HAND
</EntityType>

and

<EntitySetMapping Name="table_name">
  <EntityTypeMapping TypeName="ShardDB.table_name">
    <MappingFragment StoreEntitySet="table_name">
      <ScalarProperty Name="user_id" ColumnName="user_id" />
      <ScalarProperty Name="tenant_id" ColumnName="tenant_id" />
      ... ALL OTHER COLUMNS HERE ...
      <ScalarProperty Name="sys_user_id" ColumnName="sys_user_id" /> <= WAS MISSING THIS AND SO I HAD TO ADD IT BY HAND
    </MappingFragment>
  </EntityTypeMapping>
</EntitySetMapping>

After changing it in Visual Studio Code and getting back to Visual Studio it asked me to reload the .edmx file since it was modified. Reloaded and then hit F5 to run the code. It started working as expected.

1
  • 1
    I had moved a column in the designer from one table to another. I also had to update the previous table to remove the mappings in the same two places. Thanks!
    – dwilli
    Jan 26 at 17:45
0

I had the same issue with Visual Studio 2017 and Entity Framework 6 on a Database First model, upon refreshing it to get new columns.

I tried everything above but the only thing that worked was to delete the EDMX and generate a new one.

0

I have this error (Error 3007: Problem in mapping fragments starting at lines ... ) , after add a table to .edmx

First I delete the last added table, then I re-update the model wiht that table, but checking the 'include foreing key checkbox:

enter image description here

0

Entity Framework error - Error 11009: Property is not mapped

The reason for this error is there is no proper sync between the DB and the .edmx file.

Solution 1

Delete the model from the .edmx file and add it again.

Solution 2

Edit the .edmx file by right clicking it.

Add the updated/new property at the two following places;

Under:

<EntityType Name="TableName"> <Property Name="SaleFinYear" Type="varchar" MaxLength="50" />

Under`:

<MappingFragment StoreEntitySet="TableName"> <ScalarProperty Name="SaleFinYear" ColumnName="SaleFinYear" />

For more details with screenshots check - here

0

when you change the name of your column and try to update to the database, it loses its mapping.

Solution: 1- right-click on the table that has property not mapped at. 2- select the table mapping option. 3- you will find the not mapped property doesn't have mapping. enter image description here

0

Try to mape it in the xml file of your model :

<ScalarProperty Name="CampaignKey" ColumnName="CampaignKey" />

It works for me.

1
  • This question already has enough answers in this direction. Each answer only lengthens the tails of answers. Mar 5, 2022 at 17:09

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.