When updating the entity framework diagram using the EDMX Designer, sometimes the entities under the model.TT file get deleted and I then have to undo the changes in Source Control.
What is the reason for this and what can I do to stop this from happening?
In the Model Browser, right-click the . edmx file and select Update Model from Database. Expand the Tables, Views, and Stored Procedures nodes, and check the objects you want to add to the . edmx file.
Right-click on the designer surface of the EDMX and click Update Model From Database. Now, right-click and select "Update Model from Database" to recreate the entire model again.
An . edmx file is an XML file that defines an Entity Data Model (EDM), describes the target database schema, and defines the mapping between the EDM and the database. An . edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically.
I had the same problem one year ago. As far as I know, it's a bug that happens when you have some strange/redundant relationship in your database. Entity Framework loses its mind while updating the classes.
Delete your model, and create it without the last table you created. If this does not work, try to re-create with just a few tables ... keep updating the table by table until you find the one that is causing the problem.
Keep in mind that Database-first model (with EDMX) is "practically deprecated", EF 7 does not support it anymore. More information: http://blogs.msdn.com/b/adonet/archive/2014/10/21/ef7-what-does-code-first-only-really-mean.aspx
Hope it helps!
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