Entity Framework 5, switch from code first to database first?

我只是一个虾纸丫 提交于 2019-12-20 14:41:55

问题


I've already created a database using code first. It worked well. Many changes have since been made to the database outside Visual Studio. So many that any attempt at migration generates errors. So my question is, is there a way to switch a solution from code first to database first?


回答1:


This should be easy, just create a new, database first model and delete your code first model. Most of your code will compile just fine if you are in the same namespace and take care of naming your context in the same way.

Switching to database first however, makes you lose the ability to migrate which is a solid advantage of the code first approach. If I were you, I would spend more time on trying to create a migration, even write one manually if the generator fails but still stick with the code first.



来源:https://stackoverflow.com/questions/18879513/entity-framework-5-switch-from-code-first-to-database-first

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