c# - 无法读取 sqlite 数据库,在 visual studio 2013 中使用 Entity Framework

标签 c# wpf entity-framework sqlite visual-studio-2013

在引用了几乎所有与此问题相关的问题后。我找不到解决此问题的方法。

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

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

我的 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>

我几乎尝试了所有方法,但未能获得使用 Entity Framework 连接到 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 数据库执行操作的完整步骤吗? 感谢您的帮助。

最佳答案

尝试按照此链接中的详细信息

using sqllite with EF

获取安装文件,这些文件在有链接的 wiki 中引用

setup files which should register everything for you

好的,那么完成 .Net 包的设置,它注册了 DLL 并且很有用,所以你应该完成设置并且应该为你工作

关于c# - 无法读取 sqlite 数据库,在 visual studio 2013 中使用 Entity Framework ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32335290/

相关文章:

asp.net-mvc - 传递到字典中的模型项的类型为“System.Collections.Generic.List”错误

c# - 使用流将文件保存到磁盘时如何计算哈希值?

c# - 从许多多边形的并集构造多边形

wpf - xaml 中的鼠标位置 - wpf

wpf - 在WPF中获取系统的双击计时器间隔(来自控制面板的值)

.net - 如何将 StringFormat 添加到 DataTemplate 内的 Textblock?

c# - Entity Framework 无法使用二进制数组添加迁移

asp.net-mvc - MVC 更新 .edmx 文件(.msl、.csdl、.ssdl)

使用 Return void 和 object (string) 的 C# 重载

c# - 根据 XSLT 将 HTML 转换为 XML