Question

Updating your edmx to reflect changes made in your db (.net linq-to-entities)

  • So I have my edmx made.
  • Then I change my database a little bit, changing a column to from being a NOT NULL to allowing NULL.
  • I go into my edmx, right click and choose "Update Model from Database"

Now I go into my program and it hasnt actually updated... I can't put a null in the column. What do I have to do to update the edmx properly? Thank you.

 45  98506  45
1 Jan 1970

Solution

 81

Update/delete from the EDMX is not always functional. If the model doesn't get updated on clicking Update Model from Database let's say when you have updated a view/table in the DB, do the following:

1) Delete the view/table from the model diagram
2) Switch the EDMX to xml view (right click the edmx file and select "Open With")
3) Search and delete the xml entity elements
4) Switch back to EDMX view
5) Click Update Model from Database

This should reflect any kind of change you made to the DB to your EDMX. It's cumbersome, but works flawlessly.

In an ideal world, i would expect the Update Model from Database to sync the changes from DB to EDMX. But, it doesn't work most of the time.

2009-10-08

Solution

 21

What I have successfully done is this (VB.Net).

  1. make updates to the database as desired/ required
  2. Choose "Update from database" in the EDMX model, the graphical model will correctly show the new structure/tables
  3. Expand the project so that it shows all related files
  4. The two files with the "tt" extension are the ones that matter: first take the one WITHOUT the .Context. before the tt extension. right click on it and choose Run Custom Tool:

run custom tool

  1. Do the same for the .tt file with the .Context. in its name. All of your code and logical model classes will be updated.
2012-10-09