简体   繁体   中英

Database First Entity Framework Update EDMX but not Model.tt

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM