Execute Code First Migrations on Azure with Remote Connection String

爷,独闯天下 提交于 2019-12-12 09:18:08

问题


I am publishing an Azure Web App, and I'm running into a strange issue executing code first migrations.

The remote connection string for this database is working just fine if I do not check "Execute Code First Migrations".

However, if I check the box, a strange connection string with a curious misspelling, "ConnetionString", gets injected into the remote web.config:

<add name="DbContext_DatabasePublish" connectionString="DbContext_DatabasePublish.ConnetionString" providerName="System.Data.SqlClient" />

This, of course, is not a valid connection string and the EF initializer throws this exception

Format of the initialization string does not conform to specification starting at index 0

The publish behavior is also the same whether the local connection string refers to a localdb, or the connection string is not defined in the local web.config at all.

Am I missing something obvious?


回答1:


In Azure, I ultimately had to define connection strings for both DbContext and DbContext_DatabasePublish in order to get the migrations to execute. This MSDN post and this answer ultimately lead me to this conclusion.

I'm not sure why I'm not seeing more references to this issue though. It seems like it would be a common problem.



来源:https://stackoverflow.com/questions/30562237/execute-code-first-migrations-on-azure-with-remote-connection-string

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