Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating Entity Framework model, Visual Studio does not see changes

If I do any changes to my EF 5.0 model, VS does not seem to see the changes. I have tried adding a new table, which shows up fine in the model, but then if I try to use it somewhere the table does not show up in intellisense and I can't use it.

I have also tried changing datatypes of a column, which again shows up fine if I look at the .edmx model file, but visual studio will still give me compiler errors on that field because I am trying to assign the incorrect datatype.

If I delete the EDMX completely, and recreate it, then the changes work fine. but it is tiresome to regenerate from database each time when I should be able to just "update model from database" and rebuild.

I have never had these problems with EF before. Does anyone know the cause or the fix to this problem?

Thanks.

like image 887
Kyle Avatar asked Nov 19 '12 19:11

Kyle


People also ask

How do I update entity model in Visual Studio?

In the Model Browser, right-click the . edmx file and select Update Model from Database.

How do I refresh my EDMX file?

Right-click on the designer surface of the EDMX and click Update Model From Database. Now, right-click and select "Update Model from Database" to recreate the entire model again.


2 Answers

First Build your Project and if it was successful, right click on the "model.tt" file and choose run custom tool. It will fix it.

Again Build your project and point to "model.context.tt" run custom tool. it will update DbSet lists.

like image 53
Mahdi Shahbazi Avatar answered Sep 17 '22 14:09

Mahdi Shahbazi


If this is the bug with the edmx file located in a folder it is now fixed - download and install VS 2012 Update 1. You can get it from: http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update

like image 40
Pawel Avatar answered Sep 17 '22 14:09

Pawel