System.Data.ProviderIncompatibleException in Entit

2019-08-07 02:58发布

问题:

Is there any thing missing in my connection string so that i am getting this error:

An exception of type 'System.Data.ProviderIncompatibleException' occurred in EntityFramework.dll but was not handled in user code Additional information: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

This is my connection String in web.config:

<connectionStrings>
    <add name="OnlineStoreEntities" connectionString="Data Source=SERVERNAME\SQLEXPRESS;Initial Catalog=MVCOnlineShop;Integrated Security=True" providerName="System.Data.SqlClient" />
  <add name="MVCOnlineShop" connectionString="metadata=res://*/Models.ShopModel.csdl|res://*/Models.ShopModel.ssdl|res://*/Models.ShopModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=AHMADZAKARIA-PC;initial catalog=MVCOnlineShop;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

回答1:

Check your connection string in *.config file and most probably you are missing the providerName="System.Data.SqlClient". See Entity Framework Config File Settings for more information