I developed MVC project using VS2015 with MySQL as database.
I uploaded the project to azure for testing and I created a copy of my MySQL database in azure too.
However, when I tried to open the website I got this error:
[A]MySql.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySql.Data.MySqlClient.MySqlConnection. Type A originates from 'MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' in the context 'Default' at location 'D:\Windows\Microsoft.Net\assembly\GAC_MSIL\MySql.Data\v4.0_6.5.4.0__c5687fc88969c44d\MySql.Data.dll'. Type B originates from 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' in the context 'Default' at location 'D:\local\Temporary ASP.NET Files\root\0b5c8b85\f7b6d016\assembly\dl3\b34b00a3\00f26175_a4c8d101\MySql.Data.dll'.
this problem occured only in azure but the application works locally. I understood that, the problem is beacause of the MySQL connector/net version installed in azure.
Can anyone help me solve this?
I found a code to be added in .config file but it bypass the error only which is not useful for me.
Solution
add this to web.config file
<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.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>