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

前端 未结 9 1239
臣服心动
臣服心动 2021-01-30 20:07

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 somew

相关标签:
9条回答
  • 2021-01-30 20:39

    This is apparently a bug in the Entity Framework that the model does not get updated when your Edmx file is located inside a folder. The workarounds available at the moment are:

    1. Install VS 2012 Update 1 which should fix the bug.
    2. If you are not in a position to install Update 1, you will have to right click on the model.tt T4 template file and click run custom tool. This will update the classes for you.

    Hope that helps someone out there.

    Link: http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-code-generation-special-case/

    0 讨论(0)
  • 2021-01-30 20:40

    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.

    0 讨论(0)
  • 2021-01-30 20:40

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

    0 讨论(0)
  • 2021-01-30 20:45

    I've also experienced this problem with none of the classes being generated under the model.tt file. In my case it was down to issues with how I had built the DB in SQL2012. I'd set a column in a table to nullable that was also a foreign key and although I think you should be able to do this it caused a problem in EF5.

    As soon as this was cleared and the diagram updated from the database they reappeared.

    EF5 VS2013

    0 讨论(0)
  • 2021-01-30 20:48

    I searched for this answer because I had a similar situation in VS2013. In my case, I found that a simple "Clean Solution" cleared out all the old definitions.

    0 讨论(0)
  • 2021-01-30 20:57

    I also had this problem, however, right-clicking on the model.tt file and running "Custom tool" didn't make any difference for me somehow, but a comment on the page Ghlouw linked to mentioned to use the menu item "BUILD > Transform All T4 Templates." which did it for me

    0 讨论(0)
提交回复
热议问题