How do I solve “Keyword not supported: 'metadata' ”?

我的梦境 提交于 2020-07-06 10:46:47

问题


I can't connect to SQL Server and connection string of my project is:

<add name="Teleport_DEVEntities" connectionString="metadata=res://*/Data.Model.AdvertisingModel.csdl|res://*/Data.Model.AdvertisingModel.ssdl|res://*/Data.Model.AdvertisingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=*****;initial catalog=****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

I get this error:

Keyword not supported: 'metadata'

How can I fix this error?


回答1:


That connection string is only supported by Entity Framework. (To be fair, the keyword "entities" is in the key name!) If you want to use the connection string in an ADO raw connection, remove anything outside the &quot; string parts, including the &quot;s:

Change it to:

<add name="Teleport_DEVEntities" 
  connectionString="data source=*****;initial catalog=****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" 
  providerName="System.Data.EntityClient" 
/>



回答2:


It seems the connectionString is of EntityFramework Type. Possible way could be skipping metaData and then getting the complete connectionString.

The below code saved my time !!

if (connectionString.ToLower().StartsWith("metadata=")) {
    System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder efBuilder = new System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder(connectionString);
    connectionString = efBuilder.ProviderConnectionString; }



回答3:


Pass only this much it will work

<add name="Teleport_DEVEntities" connectionString="data source=*****;initial catalog=*****;User ID=****;password=*****;MultipleActiveResultsets=True" providerName="System.Data.EntityClient" />


来源:https://stackoverflow.com/questions/34635822/how-do-i-solve-keyword-not-supported-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!