问题
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