配置文件不包含必需的providerName属性,Azure Api

问题描述 投票:-1回答:1

我制作了一个天蓝色的网络应用。当我转到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 api xamarin xamarin.forms database-connection
1个回答
0
投票

这里是我的美分,对此问题:

先决条件:请确保在Azure门户网站Web应用程序配置设置中也具有相同的连接字符串值集。

  • 如果您使用的是基于设计的方法,则需要定义设计者生成的连接字符串,它看起来像这样:

   <add name="Northwind_Entities"  
     connectionString="metadata=res://*/Northwind.csdl|  
                                res://*/Northwind.ssdl|  
                                res://*/Northwind.msl;  
                       provider=System.Data.SqlClient;  
                       provider connection string=  
                           &quot;Data Source=.\sqlexpress;  
                                 Initial Catalog=Northwind;  
                                 Integrated Security=True;  
                                 MultipleActiveResultSets=True&quot;"  
     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" />
附加参考:

https://docs.microsoft.com/en-us/ef/ef6/fundamentals/configuring/connection-strings?redirectedfrom=MSDN

https://forums.asp.net/t/1858681.aspx?The+connection+string+EFDbContext+in+the+application+s+configuration+file+does+not+contain+the+required+providerName+attribute+

希望有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.