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
: 511 At:- 1/31/2019 9:41:49 AM
ASP.NET entity-framework ado-net-edmx-file

1 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.

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

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

Full Name *

Email *

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

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly