SQLite Code配置DbConfiguration
[DbConfigurationType(typeof(SQLiteConfiguration))]
public partial class rsapiEntities : DbContext
{
public rsapiEntities()
: base("name=rsapiEntities")
{ Database.SetInitializer<rsapiEntities>(new MigrateDatabaseToLatestVersion<rsapiEntities, APIDbMigrationsConfiguration>());
//this.Configuration.AutoDetectChangesEnabled = false;//关闭自动跟踪对象的属性变化
this.Configuration.LazyLoadingEnabled = false; //关闭延迟加载
//this.Configuration.ProxyCreationEnabled = false; //关闭代理类
//this.Configuration.ValidateOnSaveEnabled = false; //关闭保存时的实体验证
//this.Configuration.UseDatabaseNullSemantics = true; //关闭数据库null比较行为 //((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
//dynamically load all configuration
modelBuilder.Configurations.AddFromAssembly(typeof(rsapiEntities).Assembly); //...or do it manually below. For example,
//modelBuilder.Configurations.Add(new PartnersMap());
//modelBuilder.Configurations.Add(new EndpointPolicyMap());
//modelBuilder.Configurations.Add(new ThrottlePolicyMap()); //throw new UnintentionalCodeFirstException();
} public virtual DbSet<partners> partners { get; set; }
public virtual DbSet<endpoint_policy> endpoint_policy { get; set; }
public virtual DbSet<throttle_policy> throttle_policy { get; set; }
} internal sealed class APIDbMigrationsConfiguration : DbMigrationsConfiguration<rsapiEntities>
{
public APIDbMigrationsConfiguration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
} public class SQLiteConfiguration : DbConfiguration
{
public SQLiteConfiguration()
{
SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);
SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
Type t = Type.GetType("System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6");
FieldInfo fi = t.GetField("Instance", BindingFlags.NonPublic | BindingFlags.Static);
SetProviderServices("System.Data.SQLite", (System.Data.Entity.Core.Common.DbProviderServices)fi.GetValue(null));
}
}
SQLite Code配置DbConfiguration的更多相关文章
- EF6 使用SQLite Code First
SQLite是一款轻型关系型数据库,做一个小网站,用来替代sql server或者access数据库应该会是一个不错的选择. ASP.NET Entity Framework 6是微软平台的著名ORM ...
- android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error(Sqlite code 14): Could not open database,(OS error - 13:Permission denied)
07-24 15:03:14.490 6291-6291/com.tongyan.nanjing.subway E/SQLiteDatabase: Failed to open database '/ ...
- React-Native(二):React Native开发工具vs code配置
从网上翻阅了一些开发react-native的开发工具时,发现其实可选的工具还是比较多的Sublime Text,WebStrom,Atom+Nuclide,vs code 等.因为我用.net生态环 ...
- VS code 配置为 Python R LaTeX IDE
VS code配置为Python R LaTeX IDE VS code的中文断行.编辑功能强大,配置简单. VSC的扩展在应用商店搜索安装,快捷键ctrl+shift+x调出应用商店. 安装扩展后, ...
- VS code配置go语言开发环境之自定义快捷键及其对应操作
VS code 配置 自定义快捷键 及其对应操作 由于 vs code 的官方 go 插件不支持像 goland 一样运行当前 go 文件, 只能项目 或者 package 级别地运行, 因此有必 ...
- 利用 Settings Sync 同步vs code配置
vs code上有各种各样不同的插件,如果要在不同的电脑上使用 vs code 配置是件比较麻烦的事情,使用 Settings Sync 将 vs code 配置备份起来,当需要在其他电脑使用 vs ...
- VS Code配置初探
之前一直在用 Webstorm,看现在 VS Code 热度那么高,想着尝试一下. 熟悉编辑器的快捷键 VS Code 快捷键一览 安装使用到的插件 Chinese(修改你的编辑器语言,默认英文) E ...
- Windows 10 Mac 为Vs Code配置C/C++环境
2019-06-10 更新: 加上Mac版本的Vscode配置文件 0.前言 实现效果:右键一键编译运行C/C++文件 Vs code的代码效果很好看,也很轻量,所以想为Vs Code配置C/C++环 ...
- Visual Studio Code配置 HTML 开发环境
Visual Studio Code配置 HTML 开发环境 https://v.qq.com/x/page/l0532svf47c.html?spm=a2h0k.11417342.searchres ...
随机推荐
- Face Alignment at 3000FPS(C++版)工程配置
源地址:http://blog.csdn.net/sunshine_in_moon/article/details/49838245/ 3000FPS是人脸对齐算法,特点是速度快!我利用的是think ...
- Mysql ODBC 5.1 Driver免安装脚本
在使用Mysql 的时候,需要使用ODBC数据源的方式来连接mysql,所以常常需要用到免安装的驱动,自己参考官网的脚本, 修改了一个实用点的脚本,放出来大家一起分享: 安装mysql odbc 5. ...
- Songs
Two Steps From Hell - Strength of a Thousand Men
- GNU GPL介绍
怎样在程序中使用GNU许可证 不管使用哪种许可证,使用时须要在每一个程序的源文件里加入两个元素:一个版权声明和一个复制许可声明.说明该程序使用GNU许可证进行授权.另外在声明版权前应该说明 ...
- 树莓派玩耍笔记4 -- 树莓派ssh党必备的配置
1. 关闭桌面显示 对于ssh 党.当然不须要系统花费资源在显示上. 所以我们先在 "raspi-conifg" 下选择默认启动为Text 启动(这好像也是Raspbian 的默认 ...
- 简单深刻:为控件创建MouseEnter和MouseLeave事件(覆盖WndProc,增加对消息的处理,真简单!)——连对CM_MOUSEENTER的消息处理都是颇有深意啊!
其实很简单: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, D ...
- UIButton return(textField textView)
首先设置TextField 或 TextView的 delegate /////UITextView - (BOOL)textView:(UITextView *)textView shouldCha ...
- 调用ShellExecute需要头文件
调用ShellExecute需要头文件 #include "windows.h " #include "shellapi.h "
- hdu4635(强连通缩点)
传送门:Strongly connected 题意:求最多可以加多少边,使得最新的图还不是强连通图. 分析:最终添加完边的图,肯定可以分成两个部X和Y,其中只有X到Y的边没有Y到X的边,那么要使得边数 ...
- Android从raw、assets、SD卡中获取资源文件内容
先顺带提一下,raw文件夹中的文件会和project一起经过编译,而assets里面的文件不会~~~ 另外,SD卡获取文件需要权限哦! //从res文件夹中的raw 文件夹中获取文件并读取数据 p ...