MVC Code First Connection String. I changed it. How do I reinitialize the database?

断了今生、忘了曾经 提交于 2019-12-13 05:25:06

问题


I mean I was using a .SDF file but then had issues getting that to work with my host. So then I went back to the SQL DB I already have but I noticed that when I go to the default MVC 4 index page it is looking for that entity that I already created when I used the original DB.. but this table does not exist with the new SQL DB I switched to..

I already verified that is is pointing to the new DB buy setting the connection string in the constructer.

How do I tell the code to 'RE CREATE THE TABLE' before trying to use it ?


回答1:


If I understand your question correctly, you're looking for something like Entity Framework Migrations: http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx



来源:https://stackoverflow.com/questions/9810586/mvc-code-first-connection-string-i-changed-it-how-do-i-reinitialize-the-databa

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