Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Entity Framework Error - The specified store provider cannot be found in the configuration, or is not valid

I have written an assembly in C# to perform all data access for a MySQL database. I have successfully used the assembly (a compiled dll) in my C# winform desktop application. But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed.

I tried to use the same assembly with my asp.net Website project. Firstly I got an error about a missing connection string. This was easily solved by adding the MySQL connection string to the web.config file. I now get this error (stack trace listed below), I have tried adding the following dlls to my bin folder to resolve it but it didn't work.

MySql.Data.dll
MySql.Data.Entity.dll
MySql.Web.dll

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. 
---> System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. 
---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed. at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at System.Data.EntityClient.EntityConnection.GetFactory(String providerString) 
--- End of inner exception stack trace 
like image 574
Hoody Avatar asked Jan 02 '12 20:01

Hoody


1 Answers

But it only works on PCs that have had the "MySQL Connector Net 6.4.4" installed.

Does it mean that you are trying to run your code on machine where the provider is not installed? In such case you must also register the provider in your configuration file because installation adds it to machine.config and if you didn't install it the provider is currently not registered.

Try to add this to your web.config file:

<system.data>
  <DbProviderFactories>
    <add name="MySQL Data Provider" 
         invariant="MySql.Data.MySqlClient" 
         description=".Net Framework Data Provider for MySQL"  
         type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </DbProviderFactories>
</system.data>
like image 177
Ladislav Mrnka Avatar answered Sep 29 '22 02:09

Ladislav Mrnka