簡體   English   中英

無法確定“System.Data.SQLite.SQLiteFactory”類型的提供程序工廠的提供程序名稱。 使用Nuget包版本1.0.94.1

[英]Unable to determine the provider name for provider factory of type 'System.Data.SQLite.SQLiteFactory'. with the Nuget package version 1.0.94.1

我在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>

再添加一個提供商

<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

對我有用的是遵循SQLite票證中 2015-04-29 08:33:33的評論:

如果您將項目目標平台從4.5.1切換到4並重新安裝nuget包,您將完成所有工作(即使您稍后將其返回到4.5.1)“

可能會對配置Mihail的答案產生類似的影響,不確定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM