我在Windows 7-x64上使用Visual Studio 2013 Professional和.Net 4.5。我安装了Firebird 2.5.4-x64。
我知道其他人可以将Firebird与Entity Framework 6结合使用,我通过阅读大量博客和stackoverflow帖子自行解决了几个问题。但是我已经尝试了所有我能想到的东西而且我完全陷入困境。在我完全放弃使用Firebird之前我想过,我看看是否有人可以帮我弄清楚我做错了什么。
关于如何在visual studio中配置firebird似乎有很多过时的信息,我已经尝试了很多变种,但我认为这是正确的过程:
我确认已更新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>
我成功构建了项目
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代替!)
有谁知道我怎么能克服这个错误?还有什么我可以看到或做的事情试图弄明白吗?谢谢你的帮助!
答案 0 :(得分: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.config
here。
同样repository可能会让你先行,虽然这只是基本安装NuGet包的结果。更多详情here。
答案 1 :(得分:0)
哇!我终于弄清楚发生了什么。我使用Manage NuGet Packages...
来安装软件包,看起来所有安装都没问题。我正在关注另一个让我使用Package Manager Console&amp; amp;我收到错误,因为我的项目位于网络共享上。所以,我想知道火鸟的东西是否也有类似的问题。
果然,当我在控制台中运行install-package entityframework.firebird
时,我看到了错误!这可以解释为什么我的app.config文件没有得到更新。现在,an Entity Framework database provider compatible with this version could
not be found
消息完全有道理。当出现问题时,Manage NuGet Packages...
不会弹出错误消息太糟糕了!这样可以节省我很多时间。