这是什么错误。
System.ArgumentException:'不支持关键字:'元数据'。'
关注行是我的app.config。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Foroush.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<connectionStrings>
<add name="ForoushEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Foroush;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<applicationSettings>
<Foroush.Properties.Settings>
<setting name="Foroush_SmsWebService_SendReceive" serializeAs="String">
<value>http://ip.sms.ir/ws/SendReceive.asmx</value>
</setting>
</Foroush.Properties.Settings>
</applicationSettings>
</configuration>
答案 0 :(得分:0)
在屏幕截图中,我看到您通过用""
替换重要部分来尝试创建Sql连接字符串而不是实体框架连接字符串来更改连接字符串。
有类似的内置方法:
var entityConnectionStringBuilder = new EntityConnectionStringBuilder(MyConnectionString);
string sqlConnectionString = entityConnectionStringBuilder.ProviderConnectionString;
return new System.Data.SqlClient.SqlConnectionStringBuilder(sqlConnectionString).UserId);
在屏幕截图代码中,您可能希望在ConnectionStringNewFormat
中使用SqlConnectionStringBuilder
作为参数,而不是MyConnectionString
(这是原始的实体框架连接字符串。但请不要使用字符串操作,但使用实体框架提供给您的代码,如上所示。