Error Could not load type System.Data.OleDb.OleDbConnection from assembly System.Data when using Scaffold-DbContext, EntityFrameworkCore.Jet, .NetCore

.net-core .net-core-2.2 entity-framework-core jet-ef-provider


I am trying to use Scaffold-DbContext from Entity Framework Core to create Models from an existing MS Access Database.

In Package Manager Console when I run the command:

Scaffold-DbContext "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Folder\Database.mdb;" EntityFrameworkCore.Jet

I get the following error:

Could not load type 'System.Data.OleDb.OleDbConnection' from assembly 'System.Data, Version=, Culture=neutral, PublicKeyToken=123123123'.

I'm using a ClassLibrary project with the following setup:

<Project Sdk="Microsoft.NET.Sdk">


  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

    <PackageReference Include="EntityFrameworkCore.Jet" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>


I'm using the EntityFrameworkCore.Jet provider.

Both x32 and x64 OleDb Dll's are in the machine:

C:\Program Files\Common Files\microsoft shared\OFFICE14\ACEOLEDB.DLL
C:\Program Files (x86)\Microsoft Office\root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16\ACEOLEDB.DLL

The x64 installed from Microsoft Access Database Engine 2010 Redistributable and the x32 from Office Professional Plus 32-bit

Scaffold SQL database works fine.

Already went to

Is something missing or this setup should work? Any help would be appreciated.

11/5/2019 11:37:23 PM

Accepted Answer

You need to target a different .Net Framework.

Actually OleDb is not ported to .Net Core.

You can try with .Net Framework 4.6 or 4.7.

4/16/2019 12:24:12 PM

Popular Answer

The following types were not available to .NET Core (outside of Preview) until September 2019:

  • System.Data.OleDb.OleDbCommand
  • System.Data.OleDb.OleDbCommandBuilder
  • System.Data.OleDb.OleDbConnection
  • System.Data.OleDb.OleDbDataAdapter
  • System.Data.OleDb.OleDbDataReader
  • System.Data.OleDb.OleDbParameter
  • System.Data.OleDb.OleDbParameterCollection
  • System.Data.OleDb.OleDbTransaction

They are now available in the System.Data.OleDb Nuget package which targets .NET Core 2.1, .NET Framework 4.6.1, .NETStandard 2.0 and other frameworks.

If you add this package you should now be able to target .NET Core or, if you prefer, multi-target both .NET Core and the .NET Framework.

See also: The GitHub issue which led to the development and release of this package.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow