Skip to content

Jet with unixODBC and MDB Tools on macOS/Linux: ODBC connection string "must be of type JetConnection" #76

@MultiCoinCharts

Description

@MultiCoinCharts

Using macOS with Access 2002 + ODBC.

<PackageReference Include="System.Data.Odbc" Version="5.0.0" />
<PackageReference Include="EntityFrameworkCore.Jet" Version="3.1.0-alpha.3" />
<PackageReference Include="EntityFrameworkCore.Jet.Odbc" Version="3.1.0-alpha.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.10" />

ODBC + Drives are installed/working via:

+ brew install unixODBC
+ brew install mdbtools --with-unixODBC

I'm using isql -k "connection-string-goes-here" to make sure Access JET4 database can read from tables or queries.

What am I running into
Inside the OnConfiguring(optionsBuilder) method of my DbContext .UseJetOdbc(connection_string) always produces errors.

optionsBuilder.UseJetOdbc(@"Driver={Microsoft Access Driver (*.mdb)};DBQ=/Users/p_m_/Desktop/access-db/open-data/Electronics-Sales.mdb;")

The error this produces

Could not find DSN nor DBQ in connect string
+ When using `isql` DBQ must be capitalized in order to recognize it as the DBQ
+ Using the string exactly above - breaks in dotnet / but works using isql
+ The Driver is just named as-is-above in the unixODBC configuration files which is why it matches Windows XP

The connection parameter must be of type JetConnection.
To get around this, we tried creating a demo project using only System.Data.Odbc

<PackageReference Include="System.Data.Odbc" Version="5.0.0" />

In that demo, we use OdbcConnectionStringBuilder with OdbcConnection to access our Access Office XP database. This works, even on macOS with .dylib patched in ODBC Drivers.

What can I do to get UseJet()/UseJetOdbc() to use my OdbcConnection?
Here the missing link to Accdb + EF Core + Unix + OData + ASP .NET Core looks to be a connection sanitization bias.

  1. Does UseJetOdbc() lowercase attributes like DBQ which are case-sensitive on Unix?
  2. EF Core Jet asks for a connection string, filename, or OdbcConnection.
  3. Is there a special version of OdbcConnection that doesn't derive from System.Data.Odbc?

I have EntityFrameworkCore.Jet.Odbc in my project - this case is not urgent, please take your time.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions