Search code examples
firebirdentity-framework-6.1ddex

Firebird EF6 DDEX VS2013 Community Update 4 Dynamic SQL Error


I am trying to read data from an old (but live) Firebird database for my company's ERP. Unfortunately, I have very little info about the Firebird database. It was made by someone else, and I'm not permitted to change it due to the conditions of our service & maintenance agreement.

I have set up the DDEX provider and EF6 provider for VS2013 as well as my project. I am attempting to create an EDM for the database. I have this error when running the Entity Data Model Wizard in Visual Studio:

An error occurred while connecting to the database. The database might be unavailable. An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred. The error message is: 'An error occurred while executing the command definition. See the inner exception for details. The inner exception caught was of type 'FirebirdSql.Data.FirebirdClient.FbException', with this error message: 'Dynamic SQL Error SQL error code = -104 Token unknown - line 6, column 8 SELECT'. The inner exception caught was of type 'FirebirdSql.Data.Common.IscException', with this error message: 'Dynamic SQL Error SQL error code = -104 Token unknown - line 6, column 8 SELECT'.'.

Here is my app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <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>
  <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>

Here is the relevant section of my machine.comfig:

<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.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c" />
    </DbProviderFactories>
</system.data>

I'm using DDEXProvider-3.0.1.0, and both of its DataTools dll's are loaded into the GAC.

I'm using EntityFramework.Firebird-4.6.0.0-NET45, and the dll, FirebirdSql.Data.FirebirdClient is in the GAC.

I'm using Entity Framework 6.1.2 in my solution from NuGet. (Originally I was using 6.0, but I got the same error.)

I'm using Firebird ADO.NET Data Provider in my solution 4.6.0.0 from NuGet.

I'm using Firebird Entity Framework Provider 4.6.0.0 in my solution from NuGet.

My data connection tests okay, and it is using Dialect 3 to communicate with the database. I have experimented with Dialect 1, but it does not solve the problem. I am currently using "none" for the character set.

In Server Explorer, I can browse all folders: Domains, System Tables, Tables, Views, and Stored Procedures with no error.

In my opinion, the error code suggests the Firebird database doesn't like the "." in column 8 of the command. Does anyone have a solution for this? Has anyone even encountered this problem?


Solution

  • Firebird Version 1.5 is too old to be used with Entity Framework. Use gbak to create a portable backup file (fbk) of your database, update the Firebird server to 2.5.3 and run gbak again to restore the database. Now EF should work for you.