我制作了一个天蓝色的网络应用。当我转到Web应用程序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"/>
<add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />
希望有帮助。