【问题标题】:Entity Framework 6 / Firebird database provider compatibility issue in Visual Studio 2013 ProfVisual Studio 2013 Prof 中的 Entity Framework 6 / Firebird 数据库提供程序兼容性问题
【发布时间】:2015-04-09 18:22:25
【问题描述】:

我在 Windows 7-x64 上使用 Visual Studio 2013 Professional 和 .Net 4.5。我安装了 Firebird 2.5.4-x64。

我知道其他人可以将 Firebird 与 Entity Framework 6 一起使用,并且通过阅读大量博客和 stackoverflow 帖子,我自己发现了几个问题。但我已经尝试了我能想到的一切,我完全被困住了。在我完全放弃使用 Firebird 之前,我想,我会看看是否有人可以帮助我找出我做错了什么。

似乎有很多关于如何在 Visual Studio 中配置 firebird 的过时信息,我已经尝试了很多变体,但这是我认为正确的过程:

  • 我安装了 FirebirdSql.Data.FirebirdClient-4.6.1.0.msi。
  • 我确认它更新了 GAC:

    The Global Assembly Cache contains the following assemblies:
    FirebirdSql.Data.FirebirdClient, Version=4.6.1.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL
    Number of items = 1
    
  • 我在 machine.config 文件中验证了它已更新:

    <system.data>
      <DbProviderFactories>
        <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=4.6.1.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/>
      </DbProviderFactories>
    </system.data>
    
  • 我安装了 DDEXProvider-3.0.1.0.msi

  • 我已验证条目已添加到注册表并且路径正确
  • 我创建了一个新的Class Library 项目
  • 我安装了以下 Nuget 包:

      <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
      <package id="EntityFramework.Firebird" version="4.6.1.0" targetFramework="net45" />
      <package id="FirebirdSql.Data.FirebirdClient" version="4.6.1.0" targetFramework="net45" />
    
  • 我确认已对 App.config 文件进行了更新。 (除了尝试下面的默认 App.config 文件,我还尝试使用像 the one in this blog 这样的文件)

    <?xml version="1.0" encoding="utf-8"?>
      <configuration>
        <configSections>
          <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        </configSections>
        <system.data>
        <DbProviderFactories>
          <remove invariant="FirebirdSql.Data.FirebirdClient" />
          <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
        </DbProviderFactories>
      </system.data>
    </configuration>
    
  • 项目搭建成功

  • 我成功添加了一个连接到现有 Firebird 数据库(Firedbird 数据提供程序和数据源显示在选项中)
  • 我尝试添加一个新的ADO.Net Entity Data Model,使用EF Designer from database 选项和我刚刚添加的数据连接
  • 当我点击Next 时出现此错误:

    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. If you have already installed a
    compatible provider, ensure you have rebuilt your project before
    performing this action. Otherwise, exit this wizard, install a compatible
    provider, and rebuild your project before performing this action.
    

如果我不安装 EntityFramework Nuget 包,则会启用 EF 5.0 选项,并且在使用 5.0 时不会出现此错误。 (但我真的很想改用 6.x!)

有谁知道我该如何克服这个错误?还有什么我可以查看或尝试解决的问题吗?感谢您的帮助!

【问题讨论】:

    标签: entity-framework-6 firebird


    【解决方案1】:

    您在已注册提供程序的配置中缺少entityFramework 部分。安装EntityFramework.Firebird 时,应添加设置。

    <entityFramework>
        <defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
        <providers>
            <provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
            <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>
    

    你可以看到整个App.confighere

    repository 也可能让您领先一步,尽管这只是安装 NuGet 包的基本结果。更多详情here.

    【讨论】:

    • 感谢您抽出宝贵时间帮助@cincura.net。我觉得奇怪的是,在安装了 nuget 包之后,App.config 似乎缺少了一些东西。这就是为什么我在我的问题中提到我也尝试了不同的配置文件(实际上它是由你引用的同一个人提供的)。为了希望与我之前尝试的有所不同,我将您链接到的那个复制/粘贴到我的项目中,但它没有任何效果。
    【解决方案2】:

    哇!我终于弄清楚发生了什么。我正在使用Manage NuGet Packages... 来安装软件包,看起来一切都没有问题。我正在关注另一个让我使用包管理器控制台的教程,但由于我的项目位于网络共享上,因此出现错误。所以,我想知道火鸟的东西是否也有类似的问题。

    果然,当我在控制台中运行install-package entityframework.firebird 时,我看到了错误!这可以解释为什么我的 app.config 文件没有得到更新。现在an Entity Framework database provider compatible with this version could not be found 消息完全有意义。太糟糕了Manage NuGet Packages... 在出现问题时不会弹出错误消息!那会为我节省大量时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      • 1970-01-01
      • 2015-10-29
      相关资源
      最近更新 更多