SQlite实体框架ADO.net提供者错误1.0.92.0 [英] SQlite Entity Framework ADO.net provider error 1.0.92.0

查看:135
本文介绍了SQlite实体框架ADO.net提供者错误1.0.92.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图了解SQlite和实体框架如何交互。
我在我的visual studio 2013中创建了一个新的新的控制台项目。我安装了SQlite 1.0.92的nuget数据包。
我创建一个新的空模型(edmx),并尝试从静态示例数据库(如northwind.db)填充它。
此后,我收到此错误:错误0175:名为System.Data.SQLite.EF6的ado.net提供程序未在计算机上注册。



任何想法?



谢谢
Lorenzo

解决方案



从sqlite服务器(x86版本)下载SQLite ado.net提供程序。
您必须在GAC中手动注册这三个库:system.data.sqlite,system.data.sqlite.ef6,system.data.sqlite.designer with gacutil



启动visual studio 2013.添加对nuget sqlite 1.0.92.0的引用(这将增加对实体框架6.1的引用)。



你的app.config将会看起来像这样:

 <?xml version =1.0encoding =utf-8?> 
< configuration>
< configSections>
<! - 有关实体框架配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
< section name =entityFrameworktype =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089requirePermission =false/> ;
< / configSections>
< system.data>
< DbProviderFactories>
< remove invariant =System.Data.SQLite/>
< add name =SQLite Data Providerinvariant =System.Data.SQLitedescription =。SQLite的Net Framework数据提供程序type =System.Data.SQLite.SQLiteFactory,System.Data.SQLite />
< remove invariant =System.Data.SQLite.EF6/>
< add name =SQLite数据提供程序(实体框架6)invariant =System.Data.SQLite.EF6description =。SQLite(实体框架6)的Net Framework数据提供程序type =System .Data.SQLite.EF6.SQLiteProviderFactory,System.Data.SQLite.EF6/>
< / DbProviderFactories>
< /system.data>
< entityFramework>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework/>
< providers>
< provider invariantName =System.Data.SqlClienttype =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
< provider invariantName =System.Data.SQLite.EF6type =System.Data.SQLite.EF6.SQLiteProviderServices,System.Data.SQLite.EF6/>

< / providers>
< / entityFramework>
< connectionStrings>

在服务器资源管理器的db上添加一个新的Sqlite连接并进行测试。
现在添加并创建一个新的空的ado.net实体模型到你的项目。



这应该工作...但是当你运行应用程序并且拿起有一些记录在其中一个数据库中,你会得到一个例外,告诉你没有ado.net提供商注册你的连接(system.data.sqlite)。



转到您的配置文件并将其添加到您的提供程序部分(只需复制以前的sqlite行并剪切不变名称中的.ef6后缀):

 < provider invariantName =System.Data.SQLitetype =System.Data.SQLite.EF6.SQLiteProviderServices,System.Data.SQLite.EF6/> 

保存所有并重建应用程序。现在它的工作原理,但如果你回到模型的细节,并尝试从数据库刷新模型,您将再次获得提供者异常。评论最后一个提供者添加并重试。我的工作!!!



我认为这是由于syste.data.sqlite和system.data.sqlite.ef6之间的提供程序名称之间的冲突b
$ b

尽管我不能先做模型(项目一个模型,然后从它创建一个新的数据库),因为我得到另一个ado.net提供者异常。



有什么想法?



谢谢
Lorenzo



_________________ 更新04-2014 _________________



经过一些测试和谷歌搜索...
我读了您要使用VS设计工具,您必须安装正确的x86版本的SQLite驱动程序。这些驱动程序要与VS工具正常工作,需要在安装过程中注册其GAC中的System.Data.SQLite版本(只有在此VS知道在哪里找到设计工具的连接提供程序之后)。
当您使用模型优先的方法,并且您要求模型创建数据库,而不是使用在您的app.config中注册的正确的驱动程序时,tryes打开与在GAC中注册的实体连接的实体连接,并由visualmodel创建工具(并且不兼容)。我认为目前还没有办法使用VS的实体建模工具与SQLite提供程序。



Lorenzo


I'm trying to understand how SQlite and entity frameworks interacts. I create a new fresh console project in my visual studio 2013. I install the nuget packet of SQlite 1.0.92. I create a new empty model (edmx) and try to populate it from a static example database (such as northwind.db). After this I get this error: error 0175: the ado.net provider named "System.Data.SQLite.EF6" is not registered on the computer.

Any ideas?

Thank you Lorenzo

解决方案

After some tests I found a possible solution. Let's start from the beginning:

Download the SQLite ado.net provider from sqlite server (x86 version). You have to manually register in the GAC those three libraries: system.data.sqlite, system.data.sqlite.ef6, system.data.sqlite.designer with gacutil

Start visual studio 2013. Add reference to nuget sqlite 1.0.92.0 (This will add reference to entity framework 6.1 too).

Your app.config will look like this:

<?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>
  <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>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <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>
<connectionStrings>

Add a new Sqlite connection to the db in your server explorer and test it. Now add and create a new empty ado.net entity model to your project.

This should work... but when your run the application and pick up some records in one of the dbset you will get an exception telling you that there's no ado.net provider registered for your connection (system.data.sqlite).

Go to your config file and add this to you provider section (just copy the previous sqlite line and cut the .ef6 postfix in the invariant name):

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

Save all and rebuild the application. Now it works but if you go back to the model detail and try to refresh the model from the db you will get a provider exception again. Comment the last provider added and retry. IT WORKS!!!

I think it's due to a conflict between provider names in the syste.data.sqlite and system.data.sqlite.ef6

Despite this I can't do model first (project a model and then create a new database from it) because I get another ado.net provider exception.

Any ideas about that?

Thank you Lorenzo

_________________ UPDATE 04-2014 _________________

After some testing and googling... I read that when you want to use the VS design tools you have to install the right x86 version of the SQLite drivers. These drivers, to work properly with the VS tools, needs to register their version of the System.Data.SQLite in the GAC during the installation process (only after this VS knows where to find the connection provider for the design tools). When you use the model-first approach and you ask the model to create the db instead of use the correct driver registered in you app.config it tryes to open the entity connection with the one registered in GAC and used by the visualmodel creation tool (and wich is not compatible). I think there's no way at the moment to use the VS's entity modelling tool with the SQLite provider.

Lorenzo

这篇关于SQlite实体框架ADO.net提供者错误1.0.92.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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