1

I keep getting this error and i have no idea what's going on:

System.NotSupportedException: 'Unable to determine the provider name for provider factory of type 'Microsoft.Data.Sqlite.SqliteFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.'

This is the code I have before it:

        SqliteConnection connection = new SqliteConnection("DataSource=:memory:");
        connection.Open();

        using (MyDbContext context = new MyDbContext(connection))
        {
            var lst = context.Blogs.ToList();
        }

And this is my app.config

  <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" />
  <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
 </entityFramework>

  <system.data>
<DbProviderFactories>
  <remove invariant="System.Data.SQLite" />
  <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.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" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
 </system.data>

Please help. This thing is driving me insane. Is there something I have to put in my dbcontext for OnModelCreating?

2
  • your app.config looks rather dirty, the (apparently) same provider gets removed and added three times, you should clean that up. Also you provided two providers for the type SQLiteProviderServices, whereas the second is never registered. In the actual application code, I'd suspect that the passed connection string ("DataSource=:memory:") is no valid sqlite connection string. Commented Sep 19, 2018 at 19:49
  • learn.microsoft.com/en-us/ef/core/miscellaneous/testing/sqlite Went off of this. How would I connect to my sqlite instance? @DevilSuichiro Commented Sep 19, 2018 at 19:57

1 Answer 1

1

I had the same issue. Just remove the reference to "Microsoft.Data.Sqlite.SqliteFactory" and add "System.Data.Sqlite". Visual Studio could change this reference and messed it up

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.