9

I have developed a project with Entity Framework 6 that use a MySQL as database.. On my windows system the project is working. Now I tried to move that project on my linux machine. In order to run the project I added the MySQL dll to the GAC and to machine config. All needed dlls are also located in the project folder. When the Entity Framework access the database I am getting the following error:

System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider.
  at System.Data.Common.DbProviderFactories.GetFactory (System.Data.DataRow providerRow) [0x00000] in <filename unknown>:0

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="CashDeskServerContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;
      port=3306;database=ServerContext;uid=root;password=password;Convert Zero Datetime=True"/>
      <add name="AuditLogContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;
      port=3306;database=AuditLogContext;uid=root;password=password;Convert Zero Datetime=True"/>
  </connectionStrings>
  <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>
</configuration>

Any ideas?

THX Michael

Michael
  • 189
  • 1
  • 1
  • 11
  • I'm not sure that Mono full support EF 6. But in general this is a config problem or version problem. Can you show us your App.Config to see the configuration? – Alberto León Mar 03 '14 at 11:10
  • Hi Alberto, I added the app.config to my question... – Michael Mar 03 '14 at 13:11
  • Note that your are referencing EntityFramework.SqlServer that normally is not supported in Mono. Remove this part, please – Alberto León Mar 03 '14 at 14:57
  • @AlbertoLeón - EF6 should work on Mono. I tried a pre-release EF6 version and was able to make it work (http://blog.3d-logic.com/2013/04/14/entity-framework-6-on-mono/). The issues I hit should now be fixed. – Pawel Mar 03 '14 at 22:23

1 Answers1

7

This is because you don't seem to have the MySql ADO.NET provider configured. Take a look at my blogpost about using EF6 and MySql on Mono which shows how to resolve this exact issue (note that I wrote this post for pre-release EF6 version and the issues I hit on the road should be now fixed). Note that in the post I used DevArt MySql provider so you will have to find the correct entries to use for your provider. Also take a look at this stackoverflow post - Custom .NET Data Providers - which provides details on registering ADO.NET providers (you are most interested in DbProviderFactories part because this is what you are missing)

Community
  • 1
  • 1
Pawel
  • 31,342
  • 4
  • 73
  • 104
  • Thank you Pawel. I missed to add the attribute to my context. I fixed this and now I get the following error: System.InvalidOperationException: The configured column orders for the table 'Table' contains duplicates. Ensure the specified column order values are distinct. – Michael Mar 04 '14 at 08:24
  • This is a different issue - start a new thread with more details. I can only suspect that you used multiple `Column` attributes with the same Index value on the same table. – Pawel Mar 04 '14 at 15:46