Подтвердить что ты не робот

Не удалось определить имя поставщика для поставщика factory типа "System.Data.SQLite.SQLiteFactory". с пакетом Nuget версии 1.0.94.1

Я получаю эту ошибку с пакетом Nuget для SQLite 1.0.94.1. Я занимался различными разделами app.config, чему помогали похожие вопросы о предыдущих версиях этого пакета, но я не могу заставить его работать. Ниже приведен app.config, как я нашел его после установки пакета Nuget. Я удалил 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>
4b9b3361

Ответ 1

Добавьте еще одного поставщика

<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

Ответ 2

Что сработало для меня, так это следить за комментарием в формате SQLite:

Если вы переключите целевую платформу проекта с 4.5.1 на 4 и переустановите пакет nuget, у вас все будет работать (даже если вы вернете его обратно до 4.5.1).

Возможно, аналогичный эффект для config на Mihail отвечает, но не уверен.