Skip to content

linq2db and LINQPad

linq2db added LibRed as an Access provider in 6.6.0. It runs on Windows, Linux and macOS, needs no Access Database Engine, and gives linq2db a richer SQL dialect for Access: window functions, paging in subqueries, APPLY, INTERSECT and EXCEPT. It requires .NET 10 or later.

Add linq2db and the LibRed ADO.NET driver:

Terminal window
dotnet add package linq2db
dotnet add package LibRed.Ado --prerelease

LibRed.Ado isn’t a dependency of the linq2db package. linq2db loads each database’s ADO.NET driver at run time rather than referencing every driver for everyone, so you add the driver for the database you use. Without LibRed.Ado, the LibRed provider can’t load.

Then select the LibRed provider, either with AccessProvider.LibRed:

var options = new DataOptions().UseAccess(@"Data Source=C:\Data\Northwind.accdb", AccessProvider.LibRed);

or by the provider name ProviderName.AccessLibRed ("Access.LibRed"). A plain Data Source=<file> connection string on its own still resolves to linq2db’s classic OLE DB and ODBC providers, so name LibRed explicitly.

AccessTools.CreateDatabase and AccessTools.DropDatabase also have overloads that take an AccessProvider.

The linq2db CLI has an AccessLibRed scaffold provider. It scaffolds Access databases on any OS, with no driver installed, because the tool ships LibRed.Ado itself.

The LINQ to DB LINQPad driver (6.6.0 and later) gives Access connections a provider selector with OLE DB, ODBC and LibRed. On a non-Windows host LibRed is the default and the only choice. The driver needs LINQPad 8 or later, and LibRed isn’t in the LINQPad 5 .lpx plugin.

  1. In LINQPad, click Add connection.
  2. In Choose Data Context, click View more drivers…, find the LINQ To DB driver and click Install.
  3. Select the LINQ to DB driver and click Next.
  4. Choose Microsoft Access, pick LibRed as the provider, and give the path to your .mdb or .accdb file.

For everything else about linq2db, see the linq2db documentation and the 6.6.0 release notes.