简体   繁体   English

实体框架错误不支持关键字:provider \\ r \\ nconnection string

[英]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=&quot;data source=.\SQLEXPRESS;initial catalog=ENGeek;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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=&quot;Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0A604_ENGeek;User Id=DB_A0A604_ENGeek_admin;Password=MyPassword;App=EntityFramework&quot;" 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 &quot; 你之所以得到这个错误,是因为&quot; in your connection string. 在你的连接字符串中。 Replace &quot; 替换&quot; 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.

相关问题 关键字不支持“提供商”错误 - Keyword not supported 'provider' error 实体框架核心SQLite连接字符串关键字不受支持:版本 - Entity Framework Core SQLite Connection String Keyword not supported: version 不支持 ConnectionString 关键字中的错误:&#39;provider&#39; - Error in ConnectionString Keyword not supported: 'provider' C# 实体框架:不支持关键字:“端口” - C# Entity Framework: Keyword not supported: 'port' 实体框架提供程序错误 - Entity Framework provider error 在 C# 实体框架中使用 sql 连接字符串中的端口:不支持关键字:“端口” - Using port in sql connection string in C# Entity Framework: Keyword not supported: 'port' Entity Framework Core - 属性“Post.Videos”的类型为“List”<string> ' 当前数据库提供程序不支持</string> - Entity Framework Core - the property 'Post.Videos' is of type 'List<string>' which is not supported by the current database provider 不支持关键字:带有SqlBulkCopy的&#39;provider&#39; - Keyword not supported: 'provider' with SqlBulkCopy 不支持关键字:ASP.net Entity Framework 6中的“数据源” - Keyword not supported: 'data source' in ASP.net Entity Framework 6 不支持的关键字:我的web.config文件中的“提供程序”错误 - Keyword not supported: 'Provider' error in my web.config file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM