azure - 配置文件不包含所需的 providerName 属性,Azure Api
问题描述
我做了一个天蓝色的网络应用程序。当我转到我的网络应用程序 URL 时,它说应用程序已启动并正在运行,https://nameofmyapp.azurewebsites.net/。
当我尝试通过转到https://nameofmyapp.azurewebsites.net/api/Menus来发送对 Web API 的请求以获取 JSON 文本时,我收到此错误
{
"Message": "An error has occurred.",
"ExceptionMessage": "The connection string 'PetSchedulerDbContext' in the application's configuration file does not contain the required providerName attribute.\"",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)\r\n
这是我的连接字符串:
<connectionStrings>
<add name="PetschedulerDbContext" connectionString="Server=tcp:petschedulerserver.database.windows.net,1433;Initial Catalog=petschedulerdb;Persist Security Info=False;User ID=Julia;Password=Network5!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" />
</connectionStrings>
我尝试将提供者名称更改为
providerName="System.Data.EntityClient"
结果相同。我不明白所需的提供商名称是什么?如果您需要更多信息,请告诉我。
解决方案
这是我对这个问题的美分:
先决条件:请确保您在 Azure 门户 Web 应用程序配置设置中也具有相同的连接字符串值集。
- 如果您使用基于设计的方法,那么您需要定义设计器生成的连接字符串,它看起来像这样:
<add name="Northwind_Entities"
connectionString="metadata=res://*/Northwind.csdl|
res://*/Northwind.ssdl|
res://*/Northwind.msl;
provider=System.Data.SqlClient;
provider connection string=
"Data Source=.\sqlexpress;
Initial Catalog=Northwind;
Integrated Security=True;
MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"/>
- 如果您没有使用设计器(如果您没有 .edmx 文件),则连接字符串应如下所示:
<add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />
希望能帮助到你。
推荐阅读
- visual-studio - TFS Visual Studio 2010,我在某些类型的合并工具选项中看不到合并更改。我该如何启用它?
- java - 在 Macos 10.13.2 上设置 IntelliJ 时出现问题
- mysql - MySQL (5.6) 是否总是将查询的整个结果集缓存在内存/磁盘中?
- go - 在 Go 中执行二进制时获取输入
- php - 以这样的方式排列记录,D 类别总是在前,然后 E 和 F 将按 1:1 的比例排列
- javascript - React 应用程序部署在 gh-pages 上,但页面返回 404
- jquery - Select2 不显示 AJAX 的结果
- mysql - SET 和 Select Query 结合在单个 MySql 查询中运行以将结果传递到 pentaho
- solr - 如何在 Solr 中设置快照目录名称?
- python - 当我在 python 中使用 PIL 库时,关于路径名的奇怪问题