首页 新闻 会员 周边

Entity Framework 6 使用SQLite数据库 Code First模式

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-06-12 00:26

在NuGet中安装到了System.Data.SQLite.EF6,配置好连接字符串后,提示没有找到SQLite的Provider。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>
  <connectionStrings>
    <add name="Default" connectionString="Data Source=Default.db;" providerName="System.Data.SQLite.EF6"/>
  </connectionStrings>
  <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.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>
</configuration>

 

错误信息如下:

Additional information: 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 config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

 

求一个可以使用的Entity Framework + SQLite Code First的例子。能运行就可以。

Soar、毅的主页 Soar、毅 | 菜鸟二级 | 园豆:299
提问于:2014-03-27 18:35
< >
分享
所有回答(4)
0

之前我做项目用的是EF4+sqlite 采用的是model first  我现在也遇到这个问题了 正在找解决方法ing

代码哥 | 园豆:187 (初学一级) | 2014-05-04 23:20
0

安装了Sqlite么?另外,项目的版本,就是x64、x86要对应上Sqlite的版本,不要用AnyCPU。

h82258652 | 园豆:293 (菜鸟二级) | 2014-05-13 14:20
3
需要在增加下面的provider才能正常运行.
 < entityFramework>
< providers>
 < provider invariantName =" System.Data.SQLite" type =" System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6 " />
    </ providers >
  </ entityFramework>
Kulle | 园豆:107 (初学一级) | 2014-10-29 11:49
0

EF6 sqlite3也试过了 的确不支持code first

十四 | 园豆:46 (初学一级) | 2016-08-02 14:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册