错误当使用Scaffold-DbContext,EntityFrameworkCore.Jet,.NetCore时,无法从程序集System.Data加载类型System.Data.OleDb.OleDbConnection。 [英] Error Could not load type System.Data.OleDb.OleDbConnection from assembly System.Data when using Scaffold-DbContext, EntityFrameworkCore.Jet, .NetCore

查看:547
本文介绍了错误当使用Scaffold-DbContext,EntityFrameworkCore.Jet,.NetCore时,无法从程序集System.Data加载类型System.Data.OleDb.OleDbConnection。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Entity Framework Core中的Scaffold-DbContext从现有的MS Access数据库创建模型。

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

在Package Manager控制台中,运行以下命令:

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

我收到以下错误:

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

我正在使用具有以下设置的ClassLibrary项目:

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

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

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

  <ItemGroup>
    <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">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

我正在使用 EntityFrameworkCore.Jet 提供程序。

x32和x64 OleDb Dll都在计算机中:

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

从Microsoft Access Database Engine 2010可重新分发的
安装的x64和从Office Professional Plus 32位的x32安装

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

Scaffold SQL数据库可以正常工作。

Scaffold SQL database works fine.

已经转到 https://github.com/bubibubi/EntityFrameworkCore.Jet/wiki/Limitations

是否缺少某些内容,或者此设置是否可行?任何帮助将不胜感激。

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

推荐答案

您需要定位到其他.Net Framework。

You need to target a different .Net Framework.

实际上OleDb并未移植到.Net Core。
https://github.com/dotnet/corefx/issues/23542

Actually OleDb is not ported to .Net Core. https://github.com/dotnet/corefx/issues/23542

您可以尝试使用.Net Framework 4.6或4.7。

You can try with .Net Framework 4.6 or 4.7.

这篇关于错误当使用Scaffold-DbContext,EntityFrameworkCore.Jet,.NetCore时,无法从程序集System.Data加载类型System.Data.OleDb.OleDbConnection。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆