参考文章:

http://www.cnblogs.com/adswads/p/3808549.html

用NUGET 引用 System.Data.SQLite.EF6  app.config 会有默认配置   其中有部分不对.不知道为什么

错误的Config

绿色不需要的虽然本身就是错的.

invariantName是SQLite type后面用了SqlProviderServices 正确的应该是SQLiteProviderServices

<providers>
<!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SQLiteProviderServices, System.Data.SQLite.EF6" />-->
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SqlProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>

正确的providers

    <providers>
<!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />-->
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>

DbProviderFactories节点添加

<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description="Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>

总之有点凌乱.

备忘一个代码.

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder(this.Database.Connection.ConnectionString);
string path = AppDomain.CurrentDomain.BaseDirectory + connstr.DataSource;
System.IO.FileInfo fi = new System.IO.FileInfo(path);
if (System.IO.File.Exists(fi.FullName) == false)
{
if (System.IO.Directory.Exists(fi.DirectoryName) == false)
{
System.IO.Directory.CreateDirectory(fi.DirectoryName);
}
SQLiteConnection.CreateFile(fi.FullName); connstr.DataSource = path;
//connstr.Password = "admin";//设置密码,SQLite ADO.NET实现了数据库密码保护
using (SQLiteConnection conn = new SQLiteConnection(connstr.ConnectionString))
{
string sql = @" CREATE TABLE User (
Id INTEGER PRIMARY KEY AUTOINCREMENT,
Name varchar (20),
Time timestamp,
Data blob,
Val real,
TestE int);";
conn.Open();
SQLiteCommand cmd = new SQLiteCommand(sql, conn);
cmd.ExecuteNonQuery();
}
}
//添加创建代码
//modelBuilder.Configurations.Add(new Blog());
}

sqlite ef6的更多相关文章

  1. 关于Visio Studio 2012使用Nuget获取Sqlite驱动包报错:“System.Data.SQLite.EF6”的架构版本与 NuGet 的版本 2.0.30625.9003 不兼容

    背景 笔者的VS2012版本比较老旧,是几年以前下载的.平时添加三方包和驱动包都是手动添加.后来了解到有Nuget这个工具,如获至宝.可是在使用过程中却出了不少问题. 最初,笔者尝试使用Nuget添加 ...

  2. Sqlite EF6注册

    在EF6使用Sqlite的时候.Sqlite需要安装sqlite-netFx40-setup-bundle-x64-2010-1.0.97.0.exe.我不想在项目发布的时候,安装的时候执行该程序,于 ...

  3. sqlite ef6 踩坑

    调试的时候配置写如下,这样写是没有问题的但是在实际环境中有问题,因为EF路径找不到.会提示错误:The underlying provider failed on open <connectio ...

  4. 【原创】sqlite ef6 踩坑

    调试的时候配置写如下,这样写是没有问题的但是在实际环境中有问题,因为EF路径找不到.会提示错误:The underlying provider failed on open <connectio ...

  5. Web重温系列(二):SQLite+EF6实现本地化存储

    本来我们的产品有着复杂的层次结构,作为客户端的C# WinForm是不操作数据库的.但是最近有个需求,需要将数据本地保存.可选的方案很多,比如文本文件或者XML序列化和反序列化,或者如access.d ...

  6. System.Data.SQLite.EF6

    2015.1.21 到目前为止这个破玩意不支持code first 建数据库 建表 代替方案   SQL Server Compact -------------------------------- ...

  7. EF6 在 SQLite中使用备忘

    == 菜鸟级选手试验在EF6中使用Sqlite,零EF基础,少量Sqlite基础.经过断断续续的很长时间 - _ -! >>连接 1. 安装 使用目前最新版本EF6.1,Sqlite1.0 ...

  8. Visual Studio 2015使用EF6的CodeFirstFromDB模式操作Sqlite数据库时Provider问题

    传送门 什么是CodeFristFromDB 问题:查询数据是遇到 “/”应用程序中的服务器错误. No Entity Framework provider found for the ADO.NET ...

  9. Visual Studio 2015使用EF6的DBFirst模式操作Sqlite数据库

    什么是DBFirst 1:到官方下载并安装32位驱动(如果你是旧版的驱动,卸载掉,然后下载最新版的,否则操作数据时会出现异常) 2:通过Nuget获取System.Data.SQLite(会默认把下面 ...

随机推荐

  1. 我的csdn博客搬家了

    把csdn上的文章都给搬到我的新博客去了, 将会在新的博客上继续写相关的技术文章 欢迎訪问: http://www.kai-zhou.com

  2. BIRT实现组内跨行计算

    问题来源:http://developer.actuate.com/community/forum/index.php?/topic/36160-dealing-with-previous-rows- ...

  3. UVA - 10249 The Grand Dinner

    Description Problem D The Grand Dinner Input: standard input Output: standard output Time Limit: 15 ...

  4. 【转】JAVA处理线程超时

    在实际业务中,由其是多线程并开业务中,经常会遇到某个线程执行超时.而程序如果不捕获这类情况,就会导致程序一直处于等待状态,从而影响后续线程的运行.比如说网络通迅.单任务下的复杂数据库查询等,通常处理这 ...

  5. 项目管理: Alpha,Beta,RC,GA,Release

    Alpha:                    Alpha是内部测试版,一般不向外部发布.也可以认为是演示版本.允许存在一定的问题(例如功能组合.异常流程处理.稳定性.性能存在部分问题)      ...

  6. css自动添加浏览器兼容前缀 autoprefixer设置

    Autoprefixer设置: preferences>key Bindings-Users {"keys":["ctrl+alt+x"],"c ...

  7. Linux chgrp

    在学习 兄弟连 linux教学视频 的时候,我将所学的 linux 命令记录在我的博客中,方便自己查阅. 权限管理命令: chgrp 基础的命令 命令名称:chgrp 命令英文原意:change fi ...

  8. Postgres中的物化节点之sort节点

    顾名思义,物化节点是一类可缓存元组的节点.在执行过程中,很多扩展的物理操作符需要首先获取所有的元组后才能进行操作(例如聚集函数操作.没有索引辅助的排序等),这时要用物化节点将元组缓存起来.下面列出了P ...

  9. 非常有用的GitHub链接

    平常开发工作中,我经常取Github上搜索项目,Clone下来学习使用,在这个过程中,发现了好多比较好的Github地址,记录下来,分享出去. image 非常有用的GitHub链接(顺序不分先后): ...

  10. 初探Azure的保留实例(Reserved Instance)

    最近的Ignite 2017宣布了Azure将在年底推出保留实例(Reserved Instance).虽然在没有RI的这些年,Azure的EA Monetary Commitment同样也提供了和R ...