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! )

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Amc_rtty
  • 3,662
  • 11
  • 48
  • 73
  • 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 08 '12 at 11:05
  • Your sugegstion worked. Please rewrite as answer so I can give credits – Amc_rtty Oct 08 '12 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 .. – Vishal Sharma May 15 '13 at 07:25

14 Answers14

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.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
tjp69
  • 1,068
  • 9
  • 13
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.

Frank Visaggio
  • 3,642
  • 9
  • 34
  • 71
Thousand
  • 6,562
  • 3
  • 38
  • 46
  • 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 09 '12 at 09: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. – user1841243 Oct 09 '14 at 07: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 09 '18 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.

Dave
  • 3,273
  • 1
  • 17
  • 15
3

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

Chazza
  • 226
  • 3
  • 10
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.

Viral Jain
  • 1,004
  • 1
  • 14
  • 30
  • 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 07 '13 at 03: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 '13 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.

hullflyer
  • 157
  • 7
  • 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. –  Oct 17 '18 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.

Hazza
  • 6,441
  • 3
  • 24
  • 37
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).
CindyH
  • 2,986
  • 2
  • 24
  • 38
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.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • 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 '23 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.

chakeda
  • 1,551
  • 1
  • 18
  • 40
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

Condemateguadua
  • 576
  • 5
  • 9
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

JBES
  • 1,512
  • 11
  • 18
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

Mohamed Elhakim
  • 204
  • 1
  • 3
  • 7
0

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

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

It works for me.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253