Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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>
like image 749
Dabblernl Avatar asked Oct 12 '14 17:10

Dabblernl


People also ask

Why can't I find the provider name for provider factory?

Make sure that the ADO.NET provider is installed or registered in the application config #623 Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config. aspnetboilerplate/aspnetboilerplate#4283

Why am I getting'notsupportedexception-cannot determine the provider name'?

See output window for more details. Exception message: 'NotSupportedException: Unable to determine the provider name for provider factory of type 'System.Data.SQLite.SQLiteFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.'.

Why can’t I generate edmx with SQLite?

There is an issue with EF 6.2 which came along with the Visual Studio 2017 15.7 update that prevents the EDMX being generated with SQLite. The work around is to add the following to machine.config in the system.data -> DbProviderFactories section.


2 Answers

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

like image 156
Mihail Avatar answered Oct 05 '22 19:10

Mihail


What worked for me was to follow the comment on 2015-04-29 08:33:33 in the SQLite ticket:

If you switch project target platform from 4.5.1 to 4 and reinstall nuget package you will have it all working(even if you later return it back to 4.5.1)"

Might have a similar effect on config to Mihail's answer, not sure.

like image 38
Vimes Avatar answered Oct 05 '22 19:10

Vimes