question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

1reaction
lauxjpncommented, Feb 4, 2021

@P-Medicado Thanks for listing your research. Especially option 1 looks very promising in the long run and would just need a bit of dedication of someone to port the UCanAccess / Jackcess code to .NET.

Of course migrating projects to a different database is definitely an option as well, as you do with your translation repo.

1reaction
MultiCoinChartscommented, Feb 2, 2021

I’m sorry, the developer working on it used the JDBC UCanAccess bridge, this includes too much runtime translation for production use. We decided to stick with Access as a UI for designing databases for other database platforms.

Using Access as a web server database is a powerful experience for developers who don’t have a database engineering background. The development experience on Windows using EFC Jet is entirely doable (even Microsoft acknowledged apparently). However we have created a repo for translating mdb/accdb files into MySQL databases which are crossplatform by default.

Here are potential alternatives for Access as a web server database outside of Windows:

  1. Using UCanAccess, a JDBC cross-platform driver for Access
  2. Containerizing the Access Engine Redistributable from Microsoft
  3. Using the ESE/Jet engine open sourced 3 days ago

Access db to MySQL translator / Example Access + EFCore Jet App repo

Read more comments on GitHub >

github_iconTop Results From Across the Web

ODBC drivers not installing on Mojave / homebrew install
Jet with unixODBC and MDB Tools on macOS/Linux: ODBC connection string "must be of type JetConnection" bubibubi/EntityFrameworkCore.Jet#76.
Read more >
How to configure PGeo driver with unixODBC and MDB Tools
I am trying to properly configure the PGeo driver with unixODBC and MDB Tools for my Ubuntu system in order to convert a...
Read more >
DSN-less connection with PHP ODBC using MDBTools ...
My problem is, when using $conn = odbc_connect('logindb','',''); , I have to use the hardcoded value for the database location. Ideally, I would ......
Read more >
[mdb-dev] DSN-less connection not supported? | MDB Tools
Hi, Today, I did small tests with unixODBC / MDB Tools and I see that this tandem does not support DSN-less connections. Am...
Read more >
mdbtools | Kali Linux Tools
These are various tools for manipulating JET / MS Access database (MDB) files: utils - provides command line utilities to list tables, export...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found