.netfirebirdfirebird-embedded

How to setup .Net application to use firebird entity framework provider (for an embedded database)


I've been trying to find any documentation on how to setup the entity framework 6.0 provider for firebird database (an embedded version) without any luck in a .Net application.

Most of the documentation I could find was about the ADO.Net providers but I'm looking for the entity framework one so specifically:

1) How to setup firebird EF6 provider using the app.config 2) And optionnaly how to setup using new EF6 code setup (by overiding the DbConfiguration class : I'm unsure what to pass to SetExecutionStrategy() and SetDefaultConnectionFactory() methods for the firebird EF6 provider.

Link to the providers are here: http://www.firebirdsql.org/en/additional-downloads/

And the documentation I found on the web site about .net (but only for ADO, nothing on entity framework dlls). http://www.firebirdsql.org/en/net-examples-of-use/

The only thing I know is that for embedded database the ServerType should be 1


Solution

  • Thanks to magicandre1981 comment, I tried using NuGet instead of simply downloading the dlls from firebird's website.

    I usually avoid NuGet automatic installation packages but it helped me got further so I decided to give it a try anyway : the error message I had was no longer showing up during initialization of the entity framework context.

    I had a warning though during compilation about two assemblies sharing a dependence but a different version number and you guess right... Visual Studio wasn't nice enough to tell what were those assemblies. I just ignored it for the time being and ran my program to get a System.Data.ProviderIncompatibleException. Not that surprising with the Visual Studio warning I just ignored.

    So back to the warning and thanks to AsmSpy.exe from github (https://github.com/mikehadlow/AsmSpy), I found that:

    Reference: FirebirdSql.Data.FirebirdClient
        4.7.0.0 by EntityFramework.Firebird
        4.5.0.0 by FirebirdTest
    

    FirebirdTest is the name of my csproj which sole purpose is to test firebird with entity framework. The solution has nothing else but this project. The FirebirdSql.Data.FirebirdClient got installed because I installed it using NuGet following command:

    Install-Package EntityFramework.Firebird

    That basically means that the NuGet package did installed the wrong Firebird.Data.FirebirdClient assembly version. So I did the following

    1. Edited the NuGet packages.config file so the correct vresion of Firebird.Data.FirebirdClient assembly version would be downloaded
    2. Deleted the old version package of the Firebird.Data.FirebirdClient
    3. Forced a restore of my NuGet packages, this time the correct version was downloaded.
    4. And finally edited the app.config in my project so the bindingRedirect will use 4.7.0.0 instead of 4.5.0.0. This is found within section configuration/runtime/assemblyBinding/dependentAssembly section of the app.config file.

          <bindingRedirect oldVersion="0.0.0.0-4.7.0.0" newVersion="4.7.0.0" />
      

    So basically, the NuGet package is wrong and do not install the correct version of Firebird.Data.FirebirdClient assembly. Maybe I'm unlucky but that's usually why I'm not a fan of NuGet even if I know it's not the NuGet itself the problem.

    Anyhow, as you can see, it's not easy to make Firebird work with entity framework (and I won't tell you about the hell I'm going through right now with the Firebird DDEX package). While firebird database seems in itself very promising for an embedded database technology. The lack of proper documentation to integrate it with entity framework sadly make things a lot harder than it should.