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.
linq2db
Section titled “linq2db”Add linq2db and the LibRed ADO.NET driver:
dotnet add package linq2dbdotnet add package LibRed.Ado --prereleaseLibRed.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.
Scaffolding
Section titled “Scaffolding”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.
LINQPad
Section titled “LINQPad”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.
- In LINQPad, click Add connection.
- In Choose Data Context, click View more drivers…, find the LINQ To DB driver and click Install.
- Select the LINQ to DB driver and click Next.
- Choose Microsoft Access, pick LibRed as the provider, and give the path to your
.mdbor.accdbfile.
For everything else about linq2db, see the linq2db documentation and the 6.6.0 release notes.