参考文章:

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. arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++: Command not found 解决方法

    执行下列命令时: ndk-build -j16 出现如下错误: Android NDK: WARNING: Ignoring unknown import directory: jni/../../. ...

  2. intelliJ IDEA自动优化导入包设置

    Settings→Editor→General→Auto Import 选中Optimize imports on the fly和Add unambiguous imports on the fly ...

  3. Asp.Net Web API(六)

    Asp.Net Web API不可以需要IIS.可以自己在主机上承载一个Web API 创建WebAPI.Server项目 创建一个控制器项目的服务端 在Nuget中添加Microsoft.AspNe ...

  4. 《CLR via C#(第4版)》【PDF】下载

    <CLR via C#(第4版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382189 via C#(第4版)>[PD ...

  5. 中国IT职业培训市场经历的几波浪潮,未来的浪潮又是那一波?

    第一波 电脑普及性培训时代 2000年至2003年左右,中国正处于PC计算机普及阶段,而IT职业教育也刚开始兴起,这一波浪潮主要以计算机办公自动化.平面设计.计算机硬件维修.为主:几家大的IT培训机构 ...

  6. Android Studio 提示android.support.v4不存在的解决方法

    最近想学习仿QQ列表的侧滑删除功能,看完资料之后,发现有一堆错误,看了一下,说是不存在android.support.v4包不存在,浪费了一个多小时,终于是找到了解决方法,便是记录下来 打开file- ...

  7. 关于Object类下所有方法的简单解析

    类Object是类层次结构的根类,是每一个类的父类,所有的对象包括数组,String,Integer等包装类,所以了解Object是很有必要的,话不多说,我们直接来看jdk的源码,开始我们的分析之路 ...

  8. 数据分析与展示——Matplotlib基础绘图函数示例

    Matplotlib库入门 Matplotlib基础绘图函数示例 pyplot基础图表函数概述 函数 说明 plt.plot(x,y,fmt, ...) 绘制一个坐标图 plt.boxplot(dat ...

  9. BCryptPasswordEncoder加密及判断密码是否相同

    项目中用到了BCryptPasswordEncoder对密码进行二次加密,需要注意的是,加密后的字符串比较长,数据库的长度至少为60位. 通过BCryptPasswordEncoder的加密的相同字符 ...

  10. MySQL 如何存储长度较大的varchar与blob

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/96 最近,在工作中遇到了MySQL中如何存储长度较长的字段类型问 ...