How to connect ASP.NET to MySQL with MySQL Connect/Net

Databases > MySQL
If your application is using ASP.net+mysql database, you might get following error when publish to server:

Unable to find the requested .Net Framework Data Provider.  It may not be installed.

There are 3 ways to fix this problem. 

1) Upload your own Mysql.Data.DLL from your computer C:\Program Files\MySQL\MySQL Connector Net x.x.x\Assemblies  to your hosting account's BIN folder.  

2) If you can't find your own MysqlData.DLL,  then you can use our server's default MySQL Connector 6.6.4.0.

Edit your web.config, define Data Provider, you may refer the code below, which is based on MySQL .NET connector V6.6.4.0

Note: you may need to modify the code according to your app requirement.
 
<system.web>
    <compilation debug="true" urlLinePragmas="true">
        <assemblies>
        <add assembly="MySql.Data,Version=6.6.4.0, Culture=neutral,PublicKeyToken=C5687FC88969C44D"/>
        </assemblies>
    </compilation>
</system.web>
<system.data>
    <DbProviderFactories>
            <remove invariant="MySql.Data.MySqlClient"/>        
        <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.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
</system.data>

3) If you are using the EF connection string and got the below error message.
"Error: The specified store provider cannot be found in the configuration, or is not valid."
Please refer to below steps to fix it.
1>Install MySQL.Data with NuGET, take public token from web.cofig.
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />

2>write it to .edmx file:
<Schema Namespace="mekashrontvModel.Store" Provider="MySql.Data.MySqlClient" ProviderManifestToken="b77a5c561934e089"/>