MVC code首先连接字符串。我改变了它。我如何重新初始化数据库? [英] MVC Code First Connection String. I changed it. How do I reinitialize the database?
问题描述
我的意思是我使用的是.SDF文件,但然后有越来越与我的主机配合使用的问题。于是我又回到了SQL数据库我已经有了,但我注意到,当我去到它在寻找,当我使用的原始数据库,我已经创建了一个实体的默认MVC 4索引页..但这个表不存在与新的SQL数据库,我切换到..
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..
我已经验证了被指向新的DB买到设置连接字符串中的建筑工。
I already verified that is is pointing to the new DB buy setting the connection string in the constructer.
我如何告诉code尝试使用它之前,再创建表?
How do I tell the code to 'RE CREATE THE TABLE' before trying to use it ?
推荐答案
如果我正确地理解你的问题,你在寻找类似实体框架的迁移:<一href=\"http://www.hanselman.com/blog/EntityFramework$c$cFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx\" rel=\"nofollow\">http://www.hanselman.com/blog/EntityFramework$c$cFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx
If I understand your question correctly, you're looking for something like Entity Framework Migrations: http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx
这篇关于MVC code首先连接字符串。我改变了它。我如何重新初始化数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!