none
Refreshing .edmx Model did not update model classes RRS feed

  • Question

  • Hi,

    I've made little change in on table on SQL Server (added one more column).  Then I went in VS2012 using Entity Framework 5, right-clicked Model.edmx in Model Browser and selected 'Update Model from Database'.  In the wizard I chose Refresh rather than update to refresh my Model.

    The Model has been updated/refreshed and the new column shows in entity diagram.  But my model classes in Model.tt did not update.  Can you please suggest what would be the better way to update those classes?

    I've spent some time on-line but found nothing definite as answer.  Should I chose 'Update' rather than 'Refresh'?  Or should I drop the whole model and re-create?  Or there is a much simpler solution?

    Thank you 

    Friday, July 19, 2013 2:21 PM

Answers

  • 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.

    Regards,

    Adarsh

    • Marked as answer by Alex Teslin Monday, July 22, 2013 3:47 PM
    Monday, July 22, 2013 3:15 PM

All replies

  • Have you tried to compile after refreshing?

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, July 19, 2013 7:34 PM
  • I certainly did.  I suppose pressing F5 VS compiles and then runs an application.  Or is there an extra step to be taking within Entity Framework environment?

    It looks as I will be frequently updating/refreshing my Model .edmx file as changes will be applied to a database.  This time I had to drop/delete the whole Model and re-create it again.

    Monday, July 22, 2013 8:10 AM
  • 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.

    Regards,

    Adarsh

    • Marked as answer by Alex Teslin Monday, July 22, 2013 3:47 PM
    Monday, July 22, 2013 3:15 PM
  • Thanks Adarsh, I will try that on the next Model Refresh.

    Monday, July 22, 2013 3:22 PM
  • Yes, it worked, thank you again.
    Monday, July 22, 2013 3:47 PM
  • Hi DUde,

    It's Working Completely fine.

    thanks

    Mehul Patel

    Friday, November 15, 2013 6:43 AM
  • Worked like a charm! Thank you!!
    Wednesday, October 26, 2016 1:13 PM
  • Open edmx file with Visual Studio, right button and click "update model from database..."

    Thursday, March 16, 2017 4:37 PM
  • Thank You Adarsh!

       It worked fine for us!

    Wednesday, April 26, 2017 6:34 AM
  • thanks

    http://social.msdn.microsoft.com/Forums/en-US/dlr/thread/0334b7d9-4b4f-4c56-8f3a-60ba7a5da163

    Friday, May 26, 2017 1:12 PM
  • It worked for me. Thanks a lot
    Tuesday, December 4, 2018 12:52 PM
  • Yes, manually doing "Run Custom Tool" on each .tt file works.

    Is there a way to declare the .tt files to depend on the EDMX file so that the custom tool (Transform All T4 Templates) is automatically run whenever the EDMX file changes?

    Bruce Blodgett


    Bruce Blodgett

    Friday, April 19, 2019 2:35 PM
  • i made an account just to THANK YOU
    • Edited by isaac_mar Monday, May 6, 2019 2:07 AM
    Monday, May 6, 2019 2:07 AM
  • Also, if you are using version control, you need to be able to check out the project file (.csproj,etc.) in order to make the change to the entity model. Often times, there will not be a message that it is locked or checked out by someone else.
    Friday, May 17, 2019 10:45 PM
  • This particular problem haunted me for about an hour.  Going through a tutorial, the steps were clear - 1) add a table to the database, 2) right click inside the ..model.edmx graphic and select "Update Model From Database"

    After several tries, this article came to my attention and the solutions above do not answer why the table will not add.   After looking more closely, in the error list, there is a warning that says 

    "Warning Error 6013: The table/view 'Pluto.dbo.UserProfile' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.

    dbFirst"

    Apparently another solution to consider is to remember your new table must have a primary key associated with it.  This step is easy to miss for a newbie.

    R, J

    • Edited by Crakdkorn Tuesday, July 23, 2019 12:05 AM
    Tuesday, July 23, 2019 12:05 AM