Answered by:
Entity Not Mapped errors. How to map if table does not show in table list in mapping details?

Question
-
I am new to Entity Framework and was going to start using it going through model first design. This worked great for a little while, but now that I have more tables, I keep running into issues where when I add new entities to the designer, I get errors saying the "Entity is not mapped". However, when I go into the mapping details, the table I want to map to does not exist?
How do I correct this?
Wednesday, February 16, 2011 3:53 PM
Answers
-
Hello Nate Garvey,
Welcome to the MSDN Forum and thanks for posting here.
As your description, I think in the EF, all entities must be mapped to tables, and all properties of an entity must be mapped to database columns.
If you run the model-generation wizard, and point it to your database, you will get a valid, workable EF model. If there are foreign keys in your database, these will be replaced with "navigation properties" and "associations" between the related entities in your entity data model.
You can review Diego's blog post on databinding with the EF for more info: http://blogs.msdn.com/diego/archive/2008/10/09/quick-tips-for-entity-framework-databinding.aspx.
I hope it can help you.Have a nice day,
Jackie Sun [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Proposed as answer by Jackie-Sun Monday, February 21, 2011 9:17 AM
- Marked as answer by Jackie-Sun Thursday, February 24, 2011 2:18 AM
Friday, February 18, 2011 3:00 AM
All replies
-
Hello Nate Garvey,
Welcome to the MSDN Forum and thanks for posting here.
As your description, I think in the EF, all entities must be mapped to tables, and all properties of an entity must be mapped to database columns.
If you run the model-generation wizard, and point it to your database, you will get a valid, workable EF model. If there are foreign keys in your database, these will be replaced with "navigation properties" and "associations" between the related entities in your entity data model.
You can review Diego's blog post on databinding with the EF for more info: http://blogs.msdn.com/diego/archive/2008/10/09/quick-tips-for-entity-framework-databinding.aspx.
I hope it can help you.Have a nice day,
Jackie Sun [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Proposed as answer by Jackie-Sun Monday, February 21, 2011 9:17 AM
- Marked as answer by Jackie-Sun Thursday, February 24, 2011 2:18 AM
Friday, February 18, 2011 3:00 AM -
Hi Nate
I also get that! If you are creating the entities first and then updating the database from the model you do get the message about the tables not being mapped and then you can't select the tables you have just added.
You need to to run "Generate Database from Model" anyway. After you have run the script that it generates you will see the tables in the drop down list. Not that the mapping details window is at all intuitive. The first table on the list shows that the table is mapped on to itself! Also when you create the associations on the fly you cannot specify which are the columns in the relationship.
It seems to make it's own assumptions. In the case of a one to one relationship it created the relationship with the wrong key!
David
Thursday, April 21, 2011 12:53 PM