Tolga Evcimen
Tolga Evcimen

Reputation: 7352

Is database recovery from EF model possible?

I had a web service project, with a database integration of course :) I use Entity Framework, so I generated my EF model from my db (sql server express). Everything was okay till my computer got broke. I had my project files backed up so I recovered them. But I didn't have the db backup(shame).

As far as I know there is this concept Code First, and what I am wondering is can I use it to regenerate my db? Otherwise I'll have to try getting the db from the old disk, or rewriting the whole db.

Before going into those struggles I wanted ask and get a proper answer to this since I thought it could help others too.

Upvotes: 0

Views: 473

Answers (1)

JotaBe
JotaBe

Reputation: 39004

Of course, you can.

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

The EF workflows are "reversible" in the sense that you can go from DB to model or from model to DB, no matter if the model is a graphic EDM or a DbContext.

Upvotes: 1

Related Questions