Recover deleted field from entity structure model W / O delete object

I have several Entity Framework objects from which I deleted several fields.

(I thought that consumers of the model would not need these fields. Now it turns out that they do it.)

I need to return these fields. I tried to do "Update from the database", but this does not restore them. (I suppose I remember that I wanted them to be deleted.)

I know that I can just delete and then add the object again, but this causes other problems (I have several FK associations that need to be renamed. I don't want to repeat them again.)

How can I mark these fields for recovery?

+6
source share
1 answer

Your EDMX store collection will still list deleted fields. Database Update updates the repository collection and adds new new tables and fields to the model. Since these fields are not added again, they are not copied to the model. Basically what you said: EF remembers that you deleted them. But since they still exist in the store’s collection, you can manually add a property with the correct name and type, go to the “Mapping Information” window and associate it with the desired database field.

+9
source

Source: https://habr.com/ru/post/903420/


All Articles