ashcharlton
ashcharlton

Reputation: 143

Entity Framework 6 - Entity classes get deleted when updating edmx, why is that? and what can I do to stop it?

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?

Upvotes: 8

Views: 5780

Answers (1)

Fabio
Fabio

Reputation: 11990

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!

Upvotes: 10

Related Questions