Is it possible to restore a database from an EF model?

I had a web service project with database integration, of course :) I am using the Entity Framework, so I created my EF model from my db (sql server express). Everything was fine until my computer crashed. I had backup copies of project files, so I restored them. But I did not have a db backup (shame).

As far as I know, this Code First concept exists, and I wonder if I can use it to restore my db? Otherwise, I will have to try to get db from the old disk or rewrite the whole db.

Before going into this struggle, I wanted to ask and get the right answer to this question, because I thought that this could help others.

+1
source share
1 answer

Of course you can.

Specify the connection string in the DbContext constructor, which points to a non-existent database, and the database will be created from scratch.

EF workflows are "reversible" in the sense that you can move from a database to a model or from a model to a database, regardless of whether the model is a graphical EDM or DbContext.

+2
source

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


All Articles