本文介绍了使用远程连接字符串在Azure上执行代码首次迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发布一个Azure Web App,而我正在执行一个执行代码第一次迁移的奇怪问题。



此数据库的远程连接字符串正常工作如果我不检查执行代码第一次迁移,则罚款。





但是,如果我检查框,一个奇怪的拼写错误的连接字符串ConnetionString被注入到远程web.config中:



pre> < add name =DbContext_DatabasePublishconnectionString =DbContext_DatabasePublish.ConnetionStringproviderName =System.Data.SqlClient/>

这当然不是一个有效的连接字符串,EF初始化器会抛出这个异常

发布行为也是一样的,无论本地连接字符串是引用localdb,还是连接字符串都没有在本地web.config中定义。



我缺少一些明显的东西?

解决方案

在Azure中,我最终不得不定义连接字符串为了获得执行的迁移, DbContext DbContext_DatabasePublish 这个和最终导致我的结论



我不知道为什么我没有看到更多的引用这个问题。这似乎是一个常见的问题。


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

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?

解决方案

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.

这篇关于使用远程连接字符串在Azure上执行代码首次迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 00:59