Why is my edmx file not updating

2020-07-09 08:07发布

问题:

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.

回答1:

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.



回答2:

Make sure that you selecting the objects from Update tab



回答3:

When faced with this issue, i solved my by change the username and password...so i would say, make sure you have a valid connection string in your edmx



回答4:

I've had this issue on a number of occasions. For simple problems I've edited the edmx file by opening in the code editor ( Open With... > Source Code (Text) Editor ).

Locate the table by looking for by searching for EntityType Name="your table name".

Typically I see an entry that doesn't look right, delete it, save and close the file. Open the edmx the usual way and refresh the model and Presto problem solved.



回答5:

After updating or refreshing and not getting expected results. I worked as follows: 1. I added procedure without importing it. 2. I opened edmx with text editor and added my return types having complex type like other already present in it. 3. added all values like other procedures had.

That solved my problem!



回答6:

I faced the same issue. The most reasonable solution could be to delete .edmx file and to regenrate it. Keep in mind that you should always try to update model first if nothing work then do what I just said.