Jet with unixODBC and MDB Tools on macOS/Linux: ODBC connection string "must be of type JetConnection"
See original GitHub issueUsing 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.
- Does
UseJetOdbc()
lowercase attributes likeDBQ
which are case-sensitive on Unix? - EF Core Jet asks for a connection string, filename, or
OdbcConnection
. - Is there a special version of
OdbcConnection
that doesn’t derive fromSystem.Data.Odbc
?
I have EntityFrameworkCore.Jet.Odbc
in my project - this case is not urgent, please take your time.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14
@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.
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:
Access db to MySQL translator / Example Access + EFCore Jet App repo