Is database recovery from EF model possible?

两盒软妹~` 提交于 2019-12-11 23:18:16

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24594365/is-database-recovery-from-ef-model-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!