简体   繁体   English

单实体框架6 MySQL

[英]Mono Entity Framework 6 MySQL

I have developed a project with Entity Framework 6 that use a MySQL as database.. On my windows system the project is working. 我开发了一个使用MySQL作为数据库的实体框架6的项目..在我的Windows系统上,该项目正在运行。 Now I tried to move that project on my linux machine. 现在我试图在我的linux机器上移动该项目。 In order to run the project I added the MySQL dll to the GAC and to machine config. 为了运行项目,我将MySQL dll添加到GAC并加工配置。 All needed dlls are also located in the project folder. 所有需要的dll也位于项目文件夹中。 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 THX迈克尔

This is because you don't seem to have the MySql ADO.NET provider configured. 这是因为您似乎没有配置MySql ADO.NET提供程序。 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). 看看我的博文关于使用EF6和MySQL在单声道它展示了如何解决这个问题的确切(请注意,我写这篇文章的预发布版本EF6和我上路的问题,现在应该是固定的)。 Note that in the post I used DevArt MySql provider so you will have to find the correct entries to use for your provider. 请注意,在帖子中我使用了DevArt MySql提供程序,因此您必须找到供您的提供程序使用的正确条目。 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) 另请参阅此stackoverflow帖子 - 自定义.NET数据提供程序 - 它提供了有关注册ADO.NET提供程序的详细信息(您最感兴趣的是DbProviderFactories部分,因为这是您缺少的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM