I\'m trying to use Entity Framework with MySQL and I get the above error. I have the latest MySQL connector installed.
The full error reads:
No Entit
In my case, it was a missing reference. When you upgrade to EntityFramework 6, you need to add a reference to the assembly
System.Data.Entity
I think it's because MySql.Data.Entity.EF6 inherits from a bunch of stuff in this assembly, that it did not for previous version of EF.
When your app.config is good and all your references seem fine, it's a solution worth checking.
I've updated from EntityFramework 5.0 to 6.1 and MySQL connector 6.8.3 and only had to add the attribute to get things going again. Before adding the attribute everything would compile fine but crash at runtime.
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class DemoContext : DbContext{}
in EF5 or less, all ok. in EF6, you need to use mysql connector 6.8.x, and add DbConfigurationTypeAttribute to you DbContext:
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class DemoContext : DbContext{}
which MySqlEFConfiguration is in MySql.Data.Entity.EF6.dll in 6.8.x. Have a try!
I just had the same situation when trying to configure Visual Studio Professional 2017 environment with MySQL, ADO.NET (Database First) and EF6.
After going through hell with every connector/NET available, I got it to work with Connector/NET v6.9.10 and following the steps below.
Uninstall/remove "Connector/NET" and "MySQL for Visual Studio" if installed.
Install "MySQL for Visual Studio" v2.0.5 CTP (MySQL for Visual Studio). Note: Install MySQL for Visual Studio before Connector/NET.
Install "Connector/NET" v6.9.10 (Connector/Net). https://i.stack.imgur.com/XOT1I.jpg Note: I tried using Connector/NET v6.8, v6.10 and v8 first, but none of them worked Here you can find all Connector Versions and Compatibilities with Visual Studio IDEs, but so far this list is inaccurate.
Download and Install "EntityFramework" v6.2.0 through NuGet.
Add references to C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.dll
and
C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.Entity.EF6.dll
.
Add MySQL EF6 provider info inside App.config under entity framework providers as follow:
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</providers>
</entityFramework>
And that was it. VS2017 was ready to go for me. Hope this works for everybody, as it did for me today.
References:
Can't Create Entity Data Model - using MySql and EF6
No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider
You need to create this section in config (EF 5):
<entityFramework>
<!-- ... -->
<providers>
<provider invariantName="MySql.Data.MySqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
</providers>
</entityFramework>
Update: Use this definition for EF 6:
<entityFramework>
<!-- ... -->
<providers>
<provider invariantName="MySql.Data.MySqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</providers>
</entityFramework>
Thanks to elcool.
May just MySql provider is installed in machine-config (e. g. by .net connector installer? Also the default connection factory should be something like "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" i guess...