未获取EF的Azure网站连接字符串

时间:2022-04-08 17:18:10

I am deploying an ASP.NET web app to Azure Web Sites.

我正在将ASP.NET Web应用程序部署到Azure Web站点。

The site uses Entity Framework, and when I include the following in Web.config it runs fine:

该站点使用实体框架,当我在Web.config中包含以下内容时,它运行正常:

<connectionStrings>
  <add name="DataContext" connectionString="metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

However, if this connection string is removed and instead specified via the Azure Management Portal, an error occurs.

但是,如果删除此连接字符串并通过Azure管理门户指定,则会发生错误。

Name:  DataContext
Value: metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"
Type:  Custom

This results in the error: No connection string named 'DataContext' could be found in the application config file.

这会导致错误:在应用程序配置文件中找不到名为“DataContext”的连接字符串。

1 个解决方案

#1


10  

See similar question here.

在这里看到类似的问题

Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.

尝试将web.config中的连接字符串保留为某个值(某个测试连接字符串或某个虚拟值),例如

<connectionStrings>
  <add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>

#1


10  

See similar question here.

在这里看到类似的问题

Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.

尝试将web.config中的连接字符串保留为某个值(某个测试连接字符串或某个虚拟值),例如

<connectionStrings>
  <add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>