locked
Howto make MySQL & Entity Framework work with your website when your hosting company does not have Connector/Net installed RRS feed

  • Question

  • I installed MySQL’s Connector/Net v6.2 on my dev machine and used the Entity Framework to query a MySQL server without any problems.  Then I uploaded the same code to my hosting company’s server and I kept getting errors telling me “Unable to find the requested .Net Framework Data Provider”.  In order to make it work, I had to do the following:
    1. Uploaded MySql.Data.dll to my bin directory
    2. Uploaded MySql.Data.Entity.dll to my bin directory
    3. Added the following lines to my web.config file:

    <?xml version=”1.0″?>
    <configuration>

    <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.2.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d” />

    </DbProviderFactories>

    </system.data>


    </configuration>

    I hope this saves someone else some headaches!

    Rob

    Thursday, November 12, 2009 12:47 AM

Answers

  • 2Robert: Everything is ok, but a bit more safe way is to predicate the <add name ...> part with the <remove invariant="MySql.Data.MySqlClient">
    2Lingzhi: It is not enough to only deploy the assemblies, there is also need to register the provider in the application or machine configuration.
    Devart Team
    http://www.devart.com/dotconnect
    ADO.NET data providers for Oracle, MySQL, PostgreSQL, SQLite with Entity Framework and LINQ to SQL support
    Thursday, November 12, 2009 3:55 PM

All replies

  • Hi Rob,

     

    Welcome to ADO.NET Entity Framework and LINQ to Entities forum!

     

    To connect MySQL via Entity Framework, the corresponding data provider is necessary.  Since the provider is inside some assemblies, we can copy the dlls to where the client can load. 

     

    Thank you very much for sharing your solution and experience here.  Really helpful!

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, November 12, 2009 6:39 AM
  • 2Robert: Everything is ok, but a bit more safe way is to predicate the <add name ...> part with the <remove invariant="MySql.Data.MySqlClient">
    2Lingzhi: It is not enough to only deploy the assemblies, there is also need to register the provider in the application or machine configuration.
    Devart Team
    http://www.devart.com/dotconnect
    ADO.NET data providers for Oracle, MySQL, PostgreSQL, SQLite with Entity Framework and LINQ to SQL support
    Thursday, November 12, 2009 3:55 PM
  • @Devart team:  Thank you very much for your clarification!   :)
     

    Have a nice weekend!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, November 13, 2009 1:38 AM