Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want use sqlite with entity . i add dll file and domain class .when i run my programm , i get following error :

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite'. Make sure the provider is registered in the 'entityFramework' section of the application

My Refrence[^]

My App.Config

<?xml version="1.0" encoding="utf-8"?>
    <!-- For more information on Entity Framework configuration, visit -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameter value="v11.0" />
      <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" />
      <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" />

    <add name="ChinookContext"
"Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite"
          providerName="System.Data.SQLite" />

My Context Db Class:

class ChinookContext : DbContext
        public DbSet<Artist> Artists { get; set; }
        public DbSet<Album> Albums { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
            // Chinook Database does not pluralize table names

My Programm:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            using (var context = new ChinookContext())
                var artists = from a in context.Artists
                              where a.Name.StartsWith("A")
                              orderby a.Name
                              select a;

                foreach (var artist in artists)

thank you so much.

change this
<provider invariantname="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

to this
<provider invariantname="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
Share this answer
Member 14618031 25-Oct-19 3:05am    
Thank you that worked for me!
GB2 LOL 25-Feb-20 10:24am    
It worked for me as well. Thank you.
BTW. It's stupid that it generates such a code in App.config file. I have only installed System.Data.SQLite from nuget with dependencies.
For this issues, pls. check your root .config file. The .dll refereed to your DAL and UI/other layer may be different. Also, you may not have added the required tags in your root .config file. I have same issues, did lots of things, even uninstall the EF & re-installed it but non of solution worked. At last, I found it was issues with my root .config file, specially your connection string tag. It should be same as in your DAL App.config.

Hope it works for the guy who is facing this issue.

Share this answer
var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

use the above line of code and add refernce of the Entity Framework.SqlServer in your project it would work fine.
Share this answer
Check this tutorial:

Entity Framework for Beginners[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900