Updating your edmx to reflect changes made in your db (.net linq-to-entities)
Solution 1:
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.
Solution 2:
What I have successfully done is this (VB.Net).
- make updates to the database as desired/ required
- Choose "Update from database" in the EDMX model, the graphical model will correctly show the new structure/tables
- Expand the project so that it shows all related files
- 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:
- Do the same for the .tt file with the .Context. in its name. All of your code and logical model classes will be updated.
Solution 3:
Choosing the Update Model from Database is the best method for updating your EDMX. There are certain properties that don't get updated on the Conceptual layer.
Ensure that your Store layer has been updated by viewing it in the Model Viewer toolbox. If the Store has properly been updated then you're okay, and your database is in sync. If so, go into the visual designer, click the field, go to properties, and update the NotNull property on the Conceptual side.