I am trying to setup a project with EF on top of a firebird DB but it is generating extra quotes that the Firebird db is rejecting.
The db already exists and there is a matching record for this query there. Error is FbException: Dynamic SQL Error SQL error code = -104 Token unknown - line 2, column 4 .
However if I remove the quotes it generates in the sql the query runs.
Example
using (var context = new ContextManager())
{
var accounts = context.Accounts.Where(x => x.OBJID == 1).ToList();
}
generates sql
SELECT
"A"."OBJID" AS "OBJID"
FROM "ACCOUNT" AS "A"
Config file
<?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.6.1" />
</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>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<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>
Context class
public class ContextManager : DbContext
{
public ContextManager() : base(new FbConnection("database=xxxx.fdb;DataSource=localhost;user=xxx;password=xxxxx"),true)
{
}
public ContextManager(string connString) : base(new FbConnection(connString), true)
{
//this.Configuration.LazyLoadingEnabled = false;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
public DbSet<Account> Accounts { get; set; }
}
Account Model
[Table("ACCOUNT")]
public class Account
{
[Key]
public int OBJID { get; set; }
}
Update - checked and saw dialect 1 was set so I updated the query string to denote it, the query did not change but the error did FbException: Dynamic SQL Error SQL error code = -104 Token unknown - line 2, column 4 .
where
clause is missing. The SQL supported by Firebird is pretty close to the syntax defined in the ISO SQL standard, so you will need to be more specific than just saying "generating 'normal' sql instead of Firebird sql". If you get an error, then please show that error, or otherwise explicitly specify what is wrong.