You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:应用跨设备运行时ADO.Net提供程序'System.Data.SQLite.EF6'报错

嘿,我之前也踩过这个SQLite EF6的坑!你遇到的这个错误,本质上就是目标机器或者应用配置里没正确注册SQLite的EF6数据提供程序,给你几个亲测有效的解决步骤:

解决办法

1. 用NuGet把SQLite EF6包安装到项目

直接在你的项目里安装对应的NuGet包,这样发布时会自动把必要的依赖和配置打包进去,省得手动折腾:

Install-Package System.Data.SQLite.EF6
Install-Package System.Data.SQLite.Core

要是用的是.NET Core/.NET 5+,记得选对应的SQLite EF包哦(不过看错误信息你应该是用的.NET Framework)。

2. 检查并完善应用配置文件

打开你的App.config或者Web.config,确保里面有SQLite EF6提供程序的注册节点,没有的话手动补上:

<configuration>
  <configSections>
    <!-- 若已有entityFramework节则跳过 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <providers>
      <!-- 注册SQLite EF6提供程序 -->
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
    </DbProviderFactories>
  </system.data>
</configuration>

发布应用时一定要确保这个配置文件被同步到目标机器的应用目录里。

3. 确认依赖DLL已部署到位

发布后的应用文件夹里,必须包含这几个关键文件:

  • System.Data.SQLite.dll
  • System.Data.SQLite.EF6.dll
  • SQLite.Interop.dll(注意这个分x86和x64版本,要么根据目标机器架构选对应版本,要么两个都带上,程序会自动加载匹配的)

如果是通过NuGet安装的,这些文件默认会被复制到输出目录,但如果是手动发布的话,记得检查有没有漏带。

4. 核对项目的平台目标设置

如果你的项目平台目标设的是Any CPU,而目标机器是x64或x86,可能会导致SQLite的interop DLL加载失败。建议把项目的平台目标改成和目标机器一致的架构(比如x86或x64),这样就能避免架构不匹配的问题。

内容的提问来源于stack exchange,提问作者Eunoseer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:58:44