我的连接字符串中是否缺少任何内容以致出现此错误:
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.
这是我在 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="data source=AHMADZAKARIA-PC;initial catalog=MVCOnlineShop;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
最佳答案
检查 *.config
文件中的连接字符串,很可能您缺少 providerName="System.Data.SqlClient"
。参见 Entity Framework Config File Settings了解更多信息
关于c# - Entity Framework 中的 System.Data.ProviderIncompatibleException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44945937/