2

I am using entity Database First Entity framework. I have generated my EDMX file in visual studio, as well as the objects (in Model.tt)

I have 1 table (in this example)

Users:
Username varchar
Password varchar
Email varchar

I then added a new column "LastLoggedIn" in my database via SQL manager. So my table now looks like:

Users:
Username varchar
Password varchar
Email varchar
LastLoggedIn DateTime

I then clicked on Model.edmx file and ran the Update Model from Database. The Table was updated in the EDMX diagram, however the code (in the model.tt - users.cs) file did not update.

How do I force the objects to update after the EDMX diagram has been updated?

3
  • 2
    Delete the table from the edmx first. Then update model from database. You can right click on the model.tt and select run custom tool to generate the code. Also, you need to check if there is any warning after updating the edmx models from database. Commented Jan 14, 2016 at 2:42
  • you have to make sure when you update you also click save to save the model when you click save it will update the files. Commented Jan 14, 2016 at 2:59
  • thanks. this worked :) Commented Jan 14, 2016 at 3:34

1 Answer 1

3

EF can be a bit of a pain at times, and doesn't like to update. For tables, when this happens, delete the table from the diagram. Then save it. Then do a right click and choose to Update the edmx. This should add the updated table with the new column.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.