Entity Framework Model won’t update

So you have a Entity Framework model all laid out and you make major changes to a table (rename fields and add fields).

Now you need to update your model (you don’t want to delete it and recreate it because you have added stored procs, etc).

If you delete your table off the model and try updating your model from database.  There are some scenarios where it won’t see that you need to add back the table you deleted (don’t ask me what they are).  The table won’t show in the designer, but you won’t be able to add it back.

To get around this problem, right click on the edmx file and open with xml editor.(It will ask you if you want to close it, if you have it open, click yes)

Warning: I would recommend you back up your files before editing your xml.

Now search for your table name and delete any reference to it.  Save the xml and close it.  When you open your edmx file you will not having any trouble adding back you changed table.

One thought on “Entity Framework Model won’t update

  1. Good one to point out. This is a constant FAQ for EFv1. It’s handled better in the new designer. WHen you try to delete one or more entitie from the design surface, a question pops up asking if you want to delete the tables from the store schema also. Sometimes it’s yes (e.g. in your scenario) but sometimes no (e.g., if you want to map a single entity to multiple tables).


Got something to add?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s