views:

588

answers:

4

Recently I've began experimenting with ASP.NET MVC and the Entity Framework. Since my hostingprovider only provides me with MySQL I've been trying to set that up. Locally everything works fine, but after I publish it I get the following error:

[ProviderIncompatibleException: The store provider factory type 'MySql.Data.MySqlClient.MySqlClientFactory' does not implement the IServiceProvider interface. Use a store provider that implements this interface.]

Since I'm rather inexperienced with the configuring this and google is lacking a good answer I thought I'd try here. My best guess is something missing in the web.config file, but can't really make out what it is.

Any help would be greatly appreciated!

+3  A: 

I think I've found a solution. a) I should add provider to my web.config:

  <system.data>
    <DbProviderFactories>
      <clear />
      <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.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

b) I need to reference the MySQL DLL's in my project (from the connector), just to be sure I'll use:

  • mysql.web.dll
  • mysql.data.entity.dll
  • mysql.data.dll
  • mysql.data.cf.dll

c) These files have to published along with the website, so in their properties I'll set 'Copy Local' to true.

d) Make sure the version in the web.config corresponds to the real version of the dll

Sadly I won't be able to try this for at least 8 hours (since I'm at work at the moment), but this just sprang into mind while I was doing some thinking at the place we do our best thinking. EDIT: works :)

Oxymoron
A: 

I had the same issue (mysql, publishing website to host, VS2008, MySql Connector 6.1.3.0). I had to do a few things to get this to work with my hosting site. I found these solutions on another site, sorry I don't have the links so I can't give the credit to them.

Firstly I added references like mentioned above. As well as the dbFactories code to use the DLL's in my BIN folder and not the servers GAC.

Secondly I had to create individual msl, ssdl, csdl (I did this by creating a windows form application and change the manifest to 'copy to output directory'). I placed these files in my APP_DATA directory of the website.

I then changed my connection string to something like below. Also the connection string was initially created with 'quot' instead of single apostrophe's? A bug I suppose.

add name="classEntities" connectionString="metadata=~\App_Data\Model.csdl|~\App_Data\Model.ssdl|~\App_Data\Model.msl;provider=MySql.Data.MySqlClient;provider connection string='server=hostServer;user id=myUsername;password=myPassword;database=schema'" providerName="System.Data.EntityClient"

Hope this helps someone, I spent well over a week or two getting this sorted out.

Chris
A: 

I had the same problem on my deployment platform, and it works fine now. The web config configuration is essential

Thanks a lot

David
A: 

Files listed above are the dependant assemblies for MySql.Data.dll and must be in bin folder but only in case if mysql.data.msi package is not installed on the server where your web application is hosted. Else no need to put these files on bin folder.

Just install mysql.data.msi on the server and only put MySql.Data.dll in bin folder and application run successfully.

Habib Hameed [email protected]

Habib Hameed