Entity Framework error - Error 11009: Property ' ' is not mapped

C#Entity FrameworkVisual Studio-2008Mapping

C# Problem Overview


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

C# Solutions


Solution 1 - C#

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.

Solution 2 - C#

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.

Solution 3 - C#

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.

Solution 4 - C#

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.

Solution 5 - C#

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

Solution 6 - C#

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.

Solution 7 - C#

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

Solution 8 - C#

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.

Solution 9 - C#

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

Solution 10 - C#

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.

Solution 11 - C#

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.

Solution 12 - C#

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

Solution 13 - C#

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

Solution 14 - C#

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

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

It works for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmc_rttyView Question on Stackoverflow
Solution 1 - C#ThousandView Answer on Stackoverflow
Solution 2 - C#tjp69View Answer on Stackoverflow
Solution 3 - C#DaveView Answer on Stackoverflow
Solution 4 - C#Viral JainView Answer on Stackoverflow
Solution 5 - C#ChazzaView Answer on Stackoverflow
Solution 6 - C#hullflyerView Answer on Stackoverflow
Solution 7 - C#CindyHView Answer on Stackoverflow
Solution 8 - C#chakedaView Answer on Stackoverflow
Solution 9 - C#CondemateguaduaView Answer on Stackoverflow
Solution 10 - C#Leniel MaccaferriView Answer on Stackoverflow
Solution 11 - C#HazzaView Answer on Stackoverflow
Solution 12 - C#Rahul ShakyaView Answer on Stackoverflow
Solution 13 - C#Mohamed ElhakimView Answer on Stackoverflow
Solution 14 - C#Louanes FennoucheView Answer on Stackoverflow