Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my edmx file not updating

I have a database first ASP.NET MVC 5 EF6 project. I'm using VS2015 CE. When I change my database (SQL Server 2012), I then go to VS to update my edmx file like this:

  • Double click on the edmx file in the solution explorer
  • In the edmx file right click on a blank space and select the option 'Update Model From Database'
  • I click on the button 'Finish'
  • I Rebuild the solution

When I have a table with the columns ID, Column1, Column2 and I changed Column2 into Column2Changed, my edmx has a model with ID, Column1, Column2, Column2Changed instead of ID, Column1, Column2Changed.

Also, when I change the datatype for a column, this change is not applied in my edmx.

like image 502
kwv84 Avatar asked Feb 03 '16 14:02

kwv84


People also ask

How do I Update Visual Studio 2012 EDMX?

Delete existing model and then update: 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.

How does EDMX file work?

An . edmx file is an XML file that defines an Entity Data Model (EDM), describes the target database schema, and defines the mapping between the EDM and the database. An . edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically.

How do I open an EDMX file?

Right-click on your EDMX file, select Open With…, then select XML (Text) Editor. Boom, there is your entire EDMX file as Visual Studio and . Net sees it, in all its XML wonderfulness.


2 Answers

This worked for me :

1.Build the project after updating EDMX file.

2.Right click your .tt file in solution explorer.

3.Select "Run Custom Tool" option.

This will update the .tt file.

like image 144
Dannick Bédard Avatar answered Oct 11 '22 21:10

Dannick Bédard


This is a well-known problem with Entity Framework.

"Update Model from Database" continues to be a hit-and-miss affair. Sometimes it works, often it doesn't.

Personally, I just delete the "updated" table from my .edmx file, then re-add it. Then it seems to be work okay.

like image 37
Mike Gledhill Avatar answered Oct 11 '22 21:10

Mike Gledhill