How do I update .edmx file to get new columns in Visual Studio 2017 (ASP.NET MVC)?


I was trying to update my .edmx (ADO.NET) file to get updated or you can say newly added columns, but I wasn't able to get it, what is the proper way to update  or refresh the model to get new database table columns, when the database changes.

I do not want the process of deleting the complete Models and again adding them from database.


Asked by:- neena
0
: 8229 At:- 1/31/2019 9:41:49 AM
ASP.NET entity-framework ado-net-edmx-file







2 Answers
profileImage Answered by:- jaya

You can refresh the EDMX model, by right-clicking on your EDMX file and selecting Open With -> ADO.NET Entity Data Model Designer

Right-click on the designer surface of the EDMX and click Update Model From Database.

All entities are refreshed by default, new entities are only added if you select them

If the above method doesn't work. (You can delete the entire model in .EDMX file and re-add all the tables/SP's from the database as stated below)

  • Open the EDMX designer
  • Ctrl-A to select all
  • Delete key to delete all models in the designer
  • IMPORTANT: Do not save the EDMX at this point if you are using TFS for source control!*
  • Now, right-click and select "Update Model from Database" to recreate the entire model again.
  • Rebuild project to propagate changes

It is better to use the first approach always, since many times you are working with a team of developers, and don't know which tables/Stored procedure need to re-included.

1
At:- 2/17/2019 1:05:22 PM


profileImage Answered by:- neena

You can also try this to update single column

  • Use the update model wizard (to update the storage model),
  • open the .edmx file using the designer (default),
  • find the desired scalar property and edit the desired properties in the Properties windows.

OR

Try the below steps to update complete table

  • From the Model Browser, delete the desired entity from the Entity Types section of the conceptual model and the desired table from the Tables / Views section of the storage model.
  • Then use the update model wizard to add it back.

If EDMX is still not refreshing well.

  • Select all the tables and views in the EDMX designer.
  • Delete them.
  • Then, Select "update the model from the database" and fetch all table/views again.
0
At:- 6/25/2021 12:13:48 PM Updated at:- 6/25/2021 12:16:22 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use