Updating your edmx to reflect database changes (.net linq-to-entities)

.net-3.5 entity-framework linq linq-to-entities

Question

  • Therefore, I created my edmx.
  • Then I make a little adjustment to my database, allowing NULL in a field that was previously NOT NULL.
  • I open my edmx and choose "Update Model from Database" using the right click.

Now when I access my program, it hasn't really been updated. The column cannot contain a null value. What must I do to correctly update the edmx? I'm grateful.

1
44
3/27/2009 3:52:44 PM

Accepted Answer

The easiest way to update your EDMX is to choose Update Model from Database. On the Conceptual layer, there are certain characteristics that are not changed.

Viewing your Store layer in the Model Viewer toolbox will show you if it has been updated. If the Store has been correctly updated, you're good to go and your database is synchronized. In this case, open the visual designer, click the field, choose properties, and make the necessary changes to the NotNull property on the Conceptual side.

14
3/27/2009 3:52:05 PM

Popular Answer

The EDMX's update/delete feature is sometimes broken. If, for example, after updating a view or table in the database, selecting Update Model from Database doesn't update the model, try the following:

1) Remove the table or view from the model diagram.
2) Change the EDMX view to xml (right click the edmx file and select "Open With")
3) Look up and remove any xml entity elements.
4) Return to EDMX view
5) Press the Update Model from Database button.

Any modifications you make to the DB for your EDMX should be reflected in here. Although it is complicated, it is faultless.

I would hope that the Update Model from Database will automatically sync the changes from the DB to the EDMX. However, the majority of the time it fails.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow