实体框架代码首次部署到生产主机时的迁移不起作用 [英] Entity Framework Code First Migration during deploy to production host does not work

查看:81
本文介绍了实体框架代码首次部署到生产主机时的迁移不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我使用Code First在Dev中创建我的类和表时,它工作正常。
当我通过Web Deploy发布到我的第三方主机时,所有部署都会部署,但是没有一个表在数据库中创建。连接字符串包含具有表创建对数据库访问权限的用户的适当用户名和密码。 (测试是因为我通过SSMS
使用相同的登录名/密码来成功地在托管的SQL服务器上创建表)
数据库发布连接字符串正确并具有正确的值。



当我部署ASP.Net MVC应用程序与执行代码第一迁移复选框标记为应用程序在托管服务器上抛出500错误。任何想法可能是错误的?

解决方案

由于某些原因,我必须确定添加了部署的Web.config中的EntityFramework部分,该部署不在我的本地版本的Web.config。该错误是由于存在一个EntityFramework部分引起的,但是没有指定有一个EntityFramework部分的段描述符。



我添加了部分描述符,一切正常工作。



我不知道为什么转换发生了当事情被部署,但变革是不完整的。


I am using VS2013 with Entity Framework 6.1 against SQL 2012.

When I use Code First to create my classes and tables in Dev it works fine. When I go to publish via Web Deploy to my third party host everything deploys but none of the tables are created in the DB. The connection string/s contain the appropriate username and password for a user that has table create access to the DB. (Tested because I use the same login/password via SSMS to create tables on the hosted SQL server successfully) The Database publish connection string is being made correctly and has the correct values.

When I deploy the ASP.Net MVC app with the Execute Code First Migrations checkbox marked the app throws a 500 error on the hosted server.

Any thoughts on what might be wrong?

解决方案

For some reason I have to determine there was an EntityFramework section added to the deployed Web.config that was not located in my local version of Web.config. The error was being caused by there being a EntityFramework section but there was no section descriptor specifying that there was an EntityFramework section.

I added the section descriptor and everything works correctly.

I'm not sure why the transform was happening when things were being deployed but the transform was incomplete.

这篇关于实体框架代码首次部署到生产主机时的迁移不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆