无法确定"System.Data.SQLite.SQLiteFactory"类型的提供程序工厂的提供程序名称.使用Nuget包版本1.0.94.1

Dab*_*rnl 19 .net sqlite entity-framework-6

我在SQLite 1.0.94.1的Nuget包中遇到此错误.我对各种app.config部分进行了调整,有关此软件包以前版本的类似问题的帮助,但我无法使用它.下面是我在安装Nuget包后找到的app.config.我在安装之前删除了app.config.之后我才添加了连接字符串.

那么,问题出在哪里?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <!--Added by me, the rest of the app.config was constructed by installing the SQLite package -->
  <connectionStrings>
    <add name="PrivateMessengerContext"  connectionString="DataSource=|DataDirectory|\PrivateMessengerDb.db" providerName="System.Data.SQLite.EF6"/>
    <add name="PasswordContext" connectionString="DataSource=|DataDirectory|\PasswordDb.db" providerName="System.Data.SQLite.EF6"/>
  </connectionStrings>
  <system.data>
    <!--
        NOTE: The extra "remove" element below is to prevent the design-time
          support components within EF6 from selecting the legacy ADO.NET
          provider for SQLite (i.e. the one without any EF6 support).  It
          appears to only consider the first ADO.NET provider in the list
          within the resulting "app.config" or "web.config" file.
    -->
    <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <remove invariant="System.Data.SQLite" />
      <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>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Mih*_*ail 22

再添加一个提供商

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

移动

<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />

怒吼

<remove invariant="System.Data.SQLite" />

providerName="System.Data.SQLite在您的连接字符串中更改提供程序名称.

编辑:另见http://system.data.sqlite.org/index.html/tktview/2be4298631c01be99475

  • 我有同样的问题不同之处在于我使用entityframework.6.1.3.nupkg,所以当我实现你的建议时抛出这个异常具有不变名称'System.Data.SQLite'的ADO.NET提供者要么没有在机器中注册或应用程序配置文件,或无法加载. (2认同)

Vim*_*mes 8

对我有用的是遵循SQLite票证中 2015-04-29 08:33:33的评论:

如果您将项目目标平台从4.5.1切换到4并重新安装nuget包,您将完成所有工作(即使您稍后将其返回到4.5.1)"

可能会对配置Mihail的答案产生类似的影响,不确定.

  • 奇迹般地解决了我的问题..请注意(正如答案所说); 我的平台版本只有4.5.回到平台版本4,重新安装SQLite然后返回到4.5让它工作. (3认同)