无法确定类型的供应商工厂“System.Data.SQLite.SQLiteFactory”提供者的名称。用的NuGet包版本1.0.94.1提供者、工厂、供应商、名称

2023-09-04 00:24:52 作者:戒不掉的毒

我收到此错误的的NuGet包的SQLite 1.0.94.1。我摆弄周围的不同的app.config部分,由这个包的previous版本类似的问题帮助,但我不能得到它的工作。下面是在app.config因为我发现它安装的NuGet包后。我安装它之前删除的app.config。我只在那之后加入的ConnectionStrings。

那么,问题出在哪里?

 < XML版本=1.0编码=UTF-8&GT?;
<结构>
  < configSections>
    <节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本= 6.0.0.0,文化=中性公钥= b77a5c561934e089requirePermission =FALSE/>
  < / configSections>
  <! - 增加了由我,在app.config的其余部分是通过安装包的SQLite构建 - >
  <的ConnectionStrings>
    <添加名称=PrivateMessengerContext的connectionString =数据源= | DataDirectory目录| \ PrivateMessengerDb.db的providerName =System.Data.SQLite.EF6/>
    <添加名称=PasswordContext的connectionString =数据源= | DataDirectory目录| \ PasswordDb.db的providerName =System.Data.SQLite.EF6/>
  < /的ConnectionStrings>
  < System.Data这>
    <! - 
        注意:下面的额外的删除元素是prevent设计时
          从选择传统ADO.NET中EF6支持组件
          供应商SQLite的(例如:一个没有任何EF6支持)。它
          似乎只考虑第一个ADO.NET提供者列表中
          在随后出现的的app.config或web.config文件的文件。
     - >
    < D​​bProviderFactories>
      <添加名称=SQLite的数据提供程序不变=System.Data.SQLite描述= TYPE =System.Data.SQLite.SQLiteFactory,System.Data.SQLite/&GTNET Framework数据提供的SQLite。
      <清除不变=System.Data.SQLite/>
      <清除不变=System.Data.SQLite.EF6/>
      <。NET Framework数据提供的SQLite(实体框架6)添加名称=SQLite的数据提供程序(实体框架6)不变=System.Data.SQLite.EF6描述= TYPE =System.Data.SQLite .EF6.SQLiteProviderFactory,System.Data.SQLite.EF6/>
    < / DbProviderFactories>
  < /system.data>
  <的EntityFramework>
    < defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,的EntityFramework>
      <参数>
        <参数值=mssqllocaldb/>
      < /参数>
    < / defaultConnectionFactory>
    <供应商>
      <供应商invariantName =System.Data.SqlClient的TYPE =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
      <供应商invariantName =System.Data.SQLite.EF6TYPE =System.Data.SQLite.EF6.SQLiteProviderServices,System.Data.SQLite.EF6/>
    < /供应商>
  < /的EntityFramework>
< /结构>
 

解决方案

再添加一个供应商

<供应商invariantName =System.Data.SQLiteTYPE =System.Data.SQLite.EF6.SQLiteProviderServices,System.Data.SQLite.EF6/>

移动

<添加名称=SQLite的数据提供程序不变=System.Data.SQLite描述=。NET Framework数据提供的SQLiteTYPE =System.Data.SQLite.SQLiteFactory, System.Data.SQLite/>

波纹管

<清除不变=System.Data.SQLite/>

和改变供应商名称,的providerName =System.Data.SQLite 在连接字符串。

使用System.Data.SQLite.dll访问SQLite数据库

修改: 另请参见http://system.data.sqlite.org/index.html/tktview/2be4298631c01be99475

I am getting this error with the Nuget package for SQLite 1.0.94.1. I fiddled around with the various app.config sections, helped by similar questions about previous versions of this package, but I cannot get it to work. Below is the app.config as I found it after installing the Nuget package. I deleted the app.config prior to installing it. I only added the connectionstrings after that.

So, where is the problem??

<?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>

解决方案

Add one more provider

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

move

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

bellow

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

and change the provider name to providerName="System.Data.SQLite in your connection string.

EDIT: See also http://system.data.sqlite.org/index.html/tktview/2be4298631c01be99475