After updating Entity Framework model, Visual Stud

2019-03-08 22:24发布

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.

9条回答
神经病院院长
2楼-- · 2019-03-08 22:55

Right click the .tt file and select "Run Custom Tool", that should update it: see image

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-03-08 23:10

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

查看更多
疯言疯语
4楼-- · 2019-03-08 23:11

You should have a <XXX>Model.tt file somewhere which is the T4 template that generates your model classes.

If it is in a different project, it will not update when you save the edmx file.

Anyway, try right-clicking on it in Solution Explorer and choosing Run Custom Tool

查看更多
登录 后发表回答