找不到具有不变名称'System.Data.SQLite'的ADO.NET提供程序的实体框架提供程序 [英] No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite'

查看:73
本文介绍了找不到具有不变名称'System.Data.SQLite'的ADO.NET提供程序的实体框架提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我想在实体中使用sqlite。我添加dll文件和域类。当我运行我的程序时,我收到以下错误:



找不到具有不变名称的ADO.NET提供程序的实体框架提供程序System.Data.SQLite。确保提供者在应用程序的entityFramework部分注册



我的参考



< a href =http://i.imgur.com/D5iDJl9.png> http://i.imgur.com/D5iDJl9.png [ ^ ]







我的App.Config



hi
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

http://i.imgur.com/D5iDJl9.png[^]



My App.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </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>
  <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" />
    </DbProviderFactories>
  </system.data>

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







我的上下文Db类:








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
            modelBuilder.Conventions
                .Remove<PluralizingTableNameConvention>();
        }
    }





我的程序:





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)
                {
                    Console.WriteLine(artist.Name);
                }
            }
        }
    }
}



非常感谢你。


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" />


对于这个问题,请参阅。检查你的root .config文件。 .dll会引用您的DAL,UI /其他图层可能会有所不同。此外,您可能没有在根.config文件中添加所需的标记。我有同样的问题,做了很多事情,甚至卸载EF并重新安装它,但没有解决方案工作。最后,我发现我的root .config文件存在问题,特别是你的连接字符串标签。它应该与你的DAL App.config中的相同。



希望它适用于面临这个问题的人。



谢谢!
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.

Thanks!


var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;



使用上面的代码行并在项目中添加Entity Framework.SqlServer的引用它可以正常工作。
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.


这篇关于找不到具有不变名称'System.Data.SQLite'的ADO.NET提供程序的实体框架提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆