1

I am trying to use EF 6 with MySQL and am coming up with this error message going through the connection wizard:

Your project references the latest version of Entity Framework; however an Entity Framework database provider compatible with this version could not be found for your data connection.

Searching the internet it seems this is an issue plaguing people but I can't see that anyone has a solution.

I have references to EntityFramework 6.1.1 and MySql.Data 6.9.3, Mysql.Data.Entity.EF5 and MySql.Data.Entity.EF6 versions 6.8.3. I have also tried it with MySql.Data 6.8.3 but the same thing happens.

My web.config shows the following:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices,          MySql.Data.Entity.EF6" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
</entityFramework>

Any thoughts or help would be gratefully received - otherwise I'll have to ditch MySql and go for Sql Server, putting a big hole in my schedule and an even bigger one in my wallet :-).

I have come across the post below, but it doesn;t seem to work for me:

Can't use a MySQL connection for entity framework 6

Community
  • 1
  • 1
Liam
  • 5,033
  • 2
  • 30
  • 39

1 Answers1

2

It looks to me like you have providers for both SQL Server and MySQL and the default connection factory is for the SQL Server provider. Do you need both? If not then you can remove the SQL Server parts altogether and make sure the default connection is MySQL.

Also, I notice that you have not posted the system.data portion of your config file. My working MySQL 6.9.3 config has this section.

My config looks like:

<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.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
  </entityFramework>
Andy Nichols
  • 2,952
  • 2
  • 20
  • 36
  • Thanks for coming back to me - I don't need both and have tried around a dozen different configurations. That one was a report on dev.mysql.org that somebody had got it working by adding in Sql Server... your suggestion allows me to add an EF5 model, which is a step forward. – Liam Oct 16 '14 at 06:25
  • EF5 is good enough for me - I think the biggest change I made was to directly reference the Connector/NET 6.9.4 dlls for mysql.data and mysql.data.entity.ef6 in their installed directories. My hunch with this is that the NuGet version 6.9.3 has problems. I've marked this as the answer as a proper example of a config file isn't available out there. – Liam Oct 16 '14 at 06:34