[英]Entity Framework error Keyword not supported: provider \r\nconnection string
I have made MVC API
using Entity Framework. 我使用Entity Framework制作了
MVC API
。 It worked fine on my PC as localhost on Visual studio when I published it and I hosted the api and the database on myasp.net to test it and just replaced this connectionstring : 当我发布它并在myasp.net上托管api和数据库来测试它并刚刚替换了这个连接字符串时,它在我的电脑上作为Visual Studio上的localhost工作正常。
<add name="ENGeekEntities" connectionString="metadata=res://*/Models.operation.csdl|res://*/Models.operation.ssdl|res://*/Models.operation.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=ENGeek;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
with the site connectionstring: 与站点连接字符串:
<add name="ENGeekEntities" connectionString="metadata=res://*/Models.operation.csdl|res://*/Models.operation.ssdl|res://*/Models.operation.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0A604_ENGeek;User Id=DB_A0A604_ENGeek_admin;Password=MyPassword;App=EntityFramework"" providerName="System.Data.EntityClient" />
When I try to get data it gives me this error: 当我尝试获取数据时,它给了我这个错误:
"Message":"An error has occurred.","ExceptionMessage":"Keyword not supported: 'provider \\r\\nconnection string'"
“消息”:“发生错误。”,“ExceptionMessage”:“不支持关键字:'provider \\ r \\ nconnection string'”
Any Ideas !! 有任何想法吗 !!
The reason you were getting this error because of the "
你之所以得到这个错误,是因为
"
in your connection string. 在你的连接字符串中。 Replace
"
替换
"
with single quotes '
like below. 单引号
'
如下。
<add name="ENGeekEntities" connectionString="metadata=res://*/Models.operation.csdl|res://*/Models.operation.ssdl|res://*/Models.operation.msl;provider=System.Data.SqlClient;provider
connection string='Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0A604_ENGeek;User Id=DB_A0A604_ENGeek_admin;Password=MyPassword;App=EntityFramework'" providerName="System.Data.EntityClient" />
Solved. 解决了。 There were two problems.
有两个问题。 The first problem was in serializing IEmunerable ,I repalced it with JavaScriptSerializer.
第一个问题是序列化IEmunerable,我用JavaScriptSerializer重新编写它。 The second one solved by adding single quotes Like mentioned
通过添加单引号解决了第二个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.