在没有安装数据提供程序的情况下运行migrate.exe

时间:2018-11-08 15:09:49

标签: mysql entity-framework ado.net entity-framework-migrations

我正在尝试运行migration.exe来更新数据库,而未安装mysql ADO.NET DataProvider。

  • 我将migrate.exe复制到了包含我的应用,entityframework.dllmysql.data.dll (Version 6.9.9.0)的目录
  • 我添加了带有内容的migration.config文件

migrate.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />-->
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </providers>
  </entityFramework>

  <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>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

现在我要运行以下命令

migrate.exe MyApp.Core ^
/connectionString="Server=...;database=myapp;Port=3306;Uid=root;Pwd=pwd" ^
/connectionProviderName="MySql.Data.MySqlClient"

并得到错误

ERROR: The ADO.NET provider with invariant name 'MySql.Data.MySqlClient'
is either not registered in the machine or application config file,
or could not be loaded. See the inner exception for details.

根据this stackoverflow post,这应该可以工作。我想念什么吗?

0 个答案:

没有答案