Tables don't show when re-adding them to entity-model (edmx)

Or A picture Or A · Feb 3, 2010 · Viewed 27.2k times · Source

I have a db with 5 tables. At the beginning, I've added those tables in, but then decided to remove some due to some relationship compile error.

Now, when i want to add them back, i'm opening the edmx file -> update model from database... I don't see those tables under add tab, but only under the "refresh" tab.

How can i add them back?

Answer

mathijsuitmegen picture mathijsuitmegen · Feb 5, 2010

In order to re-add a table to your model you will first need to delete the table from your model. (a list of tables is visible in the [model.Store] tree (see 'Model Browser' pane- you can open it from right-mouse click menu). When you run 'Update model from database...' the table will appear in the 'Add' tab in the first step of the 'Update Wizard'.

Steps to complete:

  1. Close your model in Visual Studio.
  2. Open your .edmx file in a text editor.
  3. Search and delete the xml entity elements (see notes below).
  4. Open your model in Visual Studio.
  5. Click Update Model from Database.

To delete all references to a table in your Model:

  • In the 'EntityContainer' element, delete all 'EntitySet' child elements that have the 'Name' attribute set to the value [TableNameToReAdd].
  • In the 'EntityContainer' element, delete all 'AssociationSet' child elements where an 'End' element exists that have their 'EntitySet' attribute set to the value [TableNameToReAdd].
  • In the 'EntityContainer' element, delete all 'EntityType' child elements where that have the 'Name' attribute set to the value [TableNameToReAdd].
  • In the 'EntityContainer' element, delete all 'Association' child elements where an 'End' element exists that have their 'Role' attribute set to the value [TableNameToReAdd].