首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.Net Framework4.5.2和Entity Framework6中两种不同的数据库访问

问.Net Framework4.5.2和Entity Framework6中两种不同的数据库访问
EN

Stack Overflow用户
提问于 2021-09-13 18:49:25
回答 1查看 74关注 0票数 0

如前所述,我必须配置两个数据库,这是MSSQL和MYSQL。对于MSSQL的情况,它可以工作,但现在我必须添加新的数据库(MySQL),但面临以下问题

代码语言:javascript
复制
The type 'MySql.Data.MySqlClient.MySqlConfiguration' does not inherit from 'System.Data.Entity.DbConfiguration'. 
Entity Framework code-based configuration classes must inherit from 'System.Data.Entity.DbConfiguration'.

对于我的app.config

代码语言:javascript
复制
<?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>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.26.0" newVersion="8.0.26.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient"></remove>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.26.0" />
    </DbProviderFactories>
  </system.data>
</configuration>
EN

回答 1

Stack Overflow用户

发布于 2021-09-14 04:51:44

基于此XML:

代码语言:javascript
复制
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />

您可能已经安装了MySql.Data.Entity.EF6 NuGet软件包。该软件包不再受支持,并且与MySql.Data 8.0.26不兼容。

卸载它,然后安装MySql.Data.EntityFramework。

(或者如果您安装了MySql.Data.Entity,请注意,根据我的answer here,它也是不兼容的。同样,卸载并替换为MySql.Data.EntityFramework。)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69167721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档