I'm having a strange problem when I update my EF model (ver 5). It deletes all of the classes that belong to that model.
My situation was like this. I changed the key column of two tables which have references to my primary table. Updating the model did not make these changes to the edmx, so I removed those three table (primary and two lookup tables), saved the edmx. Then updated the model and added those tables back in.
Once I saved the model after updating it, VS deleted all of the class files for this edmx. The edmx still looks alright with all of the tables, just the classes have gone. I then have to revert my last changes and try again.
One thing that did work was manually editing the edmx file to make the appropriate changes to the affected classes, but I don't see why I should have to do that.
Any ideas out there?
Thanks!
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.
There is no automatically refresh the EDMX (it will be nice from MS if they implement that at some point) and the best and most accurate way to refresh the EDMX is by deleting all tables in the Diagram and then deleting all complex types etc. in the Model Browser.
One way this happens after removing then re-adding a table to get EDMX to pick up a change to a Foreign Key (FK) column.
It happens because the relationships to other tables are not refreshed.
Per this answer, https://stackoverflow.com/a/34144341, to manually fix this, filter the Error List by "Build Only", and then manually resolve any build errors in the EDMX editor. Pay attention to the multiplicity of the relationships.
Alternately, use version control to revert the whole EDMX change and start again, using the following approach:
Rather than removing and re-adding only the table containing the FK column that changed, remove and re-add all tables that have any relationship to any FK column that changed.
It's been a long while, but in the end it turned out I had some errors in my edmx file which I hadn't seen, and that was causing the poco class files to not be generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With