Skip to content

EF Core provider

EntityFrameworkCore.LibRed is an EF Core provider over LibRed’s ADO.NET layer. It shares the Jet dialect’s query translation, migrations SQL and conventions with EntityFrameworkCore.Jet, but needs no driver and runs on any platform.

using Microsoft.EntityFrameworkCore;
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs => Set<Blog>();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseLibRed(@"Data Source=C:\Data\Blogging.accdb");
}

The connection string can also be a bare path: UseLibRed(@"C:\Data\Blogging.accdb"). See connection strings.

UseLibRed also has overloads that take an existing DbConnection, with or without contextOwnsConnection, and an optional Action<LibRedDbContextOptionsBuilder> for provider options.

LibRed owns both the SQL generator and the engine that runs the result, so it doesn’t have to stay within what ACE accepts. UseLibRed takes an optional LibRedSqlMode:

using EntityFrameworkCore.LibRed.Infrastructure;
optionsBuilder.UseLibRed(@"C:\Data\Blogging.accdb", LibRedSqlMode.Compatible);
Mode SQL generator Use it when
Extended (default) LibRed’s own You want the best translation. It emits standard SQL ACE has no syntax for: CROSS/OUTER APPLY, window functions, OFFSET/FETCH paging, FULL OUTER JOIN, CASE, COALESCE, NULLIF, set operations inside subquery predicates, and flat join chains.
Compatible The one EntityFrameworkCore.Jet uses The same statements also have to run against ACE.

The mode only changes what SQL EF Core generates. The engine accepts both forms either way, so raw SQL you write yourself (FromSql, ExecuteSql) can use anything in the SQL reference.

EnsureCreated and migrations create the file when it doesn’t exist. LibRed builds it page by page, with no DAO and no template file, and Access opens the result. A new file is ACE 12 (Access 2007) format by default, so it opens in every Access from 2007 onward.

A file is raised to a newer format automatically when DDL needs one: a BIGINT column needs ACE 16 and a DATETIME2 column needs ACE 17, which is also what Access itself does. The raise can’t be undone. An older Access can’t open the result, but it couldn’t have read the column either.