无法读取 sqlite 数据库,使用 Visual Studio 2013 中的实体框架

Posted

技术标签:

【中文标题】无法读取 sqlite 数据库,使用 Visual Studio 2013 中的实体框架【英文标题】:cannot read sqlite database , using entity framework in visual studio 2013 【发布时间】:2015-11-26 21:46:27 【问题描述】:

在参考了几乎所有与此问题相关的问题后。我无法找到解决此问题的方法。

我遵循了提到的所有步骤。 1)从 sqlite.org 下载包 2)从nuget安装包

仍然没有出现在实体模型向导的数据源列表中。

我的 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>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
    <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.98.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <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>
  
</configuration>

我几乎尝试了所有方法,但未能获得使用实体框架连接到 sqlite 所需的基本步骤,然后读取数据库。

我使用 DB Browser for sqlite 创建了数据库,可以通过简单的 ADO.NET 方法访问。

一旦 sqlite 显示在数据源下,然后。存在提供者错误。 比如

No-Entity-Framework-provider-found-for-the-ADO-NET

有人可以帮我完成从设置环境到在 Visual Studio 2013、.NET 4.5.1、wpf、mvvm 中对 sqlite 数据酶执行操作的完整步骤。 任何帮助表示赞赏。

【问题讨论】:

我看到你有一个连接工厂,但你的配置文件中没有连接字符串,你的代码中的连接字符串在某处吗? 连接字符串在那里。然后我将其删除并尝试再次添加数据库。没有发生。 【参考方案1】:

尝试按照此链接中的详细信息进行操作

using sqllite with EF

获取设置文件,这些文件在 wiki 中引用,有指向

的链接

setup files which should register everything for you

好的,通过 .Net 捆绑包的设置,它注册了 DLL 并且工作得很好,所以你应该通过设置并且应该为你工作

【讨论】:

我也试过这个。但我再次无法在实体模型向导中将 sqlite 视为数据源。 你的sqllite客户端安装了吗? 你能具体说明一下这个 sqlclient...因为我在网上为 SQLite 安装了所有提到的东西。 您具体安装了什么,因为您似乎缺少一些程序集才能找到它 我从提到 eerywhere 的网站安装了 SQLite DLL....版本是 1.0.98.0。然后我从 Visual Studio 安装了 EF6 包。我还尝试仅从 Visual Studio 安装它...完整的 x86 包。还是不行……

以上是关于无法读取 sqlite 数据库,使用 Visual Studio 2013 中的实体框架的主要内容,如果未能解决你的问题,请参考以下文章

Win 2K8 Server计算机上的Visual Studio 2010无法识别System.Data.Sqlite

更新 blob 后,Android sqlite 无法读取

在 Visual Studios 中创建 sqlite3.lib 文件/使用 sqlite3 [关闭]

Visual Studio下SQLite数据库开发环境设置

无法使用可读格式的 JavaScript 读取 IndexedDB sqlite 文件

带有 Ionic 4 的 SQLite?无法读取未定义类型错误的属性“then”:无法读取未定义的属性“then”