[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的更多相关文章

  1. EF6 使用SQLite Code First

    SQLite是一款轻型关系型数据库,做一个小网站,用来替代sql server或者access数据库应该会是一个不错的选择. ASP.NET Entity Framework 6是微软平台的著名ORM ...

  2. 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 '/ ...

  3. React-Native(二):React Native开发工具vs code配置

    从网上翻阅了一些开发react-native的开发工具时,发现其实可选的工具还是比较多的Sublime Text,WebStrom,Atom+Nuclide,vs code 等.因为我用.net生态环 ...

  4. VS code 配置为 Python R LaTeX IDE

    VS code配置为Python R LaTeX IDE VS code的中文断行.编辑功能强大,配置简单. VSC的扩展在应用商店搜索安装,快捷键ctrl+shift+x调出应用商店. 安装扩展后, ...

  5. VS code配置go语言开发环境之自定义快捷键及其对应操作

    VS code 配置 自定义快捷键 及其对应操作   由于 vs code 的官方 go 插件不支持像 goland 一样运行当前 go 文件, 只能项目 或者 package 级别地运行, 因此有必 ...

  6. 利用 Settings Sync 同步vs code配置

    vs code上有各种各样不同的插件,如果要在不同的电脑上使用 vs code 配置是件比较麻烦的事情,使用 Settings Sync 将 vs code 配置备份起来,当需要在其他电脑使用  vs ...

  7. VS Code配置初探

    之前一直在用 Webstorm,看现在 VS Code 热度那么高,想着尝试一下. 熟悉编辑器的快捷键 VS Code 快捷键一览 安装使用到的插件 Chinese(修改你的编辑器语言,默认英文) E ...

  8. Windows 10 Mac 为Vs Code配置C/C++环境

    2019-06-10 更新: 加上Mac版本的Vscode配置文件 0.前言 实现效果:右键一键编译运行C/C++文件 Vs code的代码效果很好看,也很轻量,所以想为Vs Code配置C/C++环 ...

  9. Visual Studio Code配置 HTML 开发环境

    Visual Studio Code配置 HTML 开发环境 https://v.qq.com/x/page/l0532svf47c.html?spm=a2h0k.11417342.searchres ...

随机推荐

  1. URL加随机数的作用

    原文:URL加随机数的作用 大家在系统开发中都可能会在js中用到ajax或者dwr,因为IE的缓存,使得我们在填入相同的值的时候总是使用IE缓存,为了解决这个问题一般可以用一下方法:        1 ...

  2. 14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量

    14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量 改变InnoDB redo ...

  3. 远程开发调试与hot-update | (R "think-of-lisper" 'Albertlee)

    远程开发调试与hot-update | (R "think-of-lisper" 'Albertlee) 远程开发调试与hot-update

  4. cocos2d-x中使用JNI的调用JAVA方法

    用cocos2d-x公布Android项目时.都应该知道要用JAVA与C/C++进行交互时会涉及到JNI的操作(Java Native Interface).JNI是JAVA的一个通用接口.旨在本地化 ...

  5. Android APP代码拨打电话、打开手机分享功能等隐式意图

    Android APP拨打电话: Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+110)); start ...

  6. Android中使用JNI获得APK签名的哈希值

    原地址:http://blog.csdn.net/i5suoi/article/details/19036975 最近在研究android应用中的安全问题,貌似只有将核心代码写到JNI底层才是最安全的 ...

  7. java过滤html标签函数

    public static String Html2Text(String inputString) {              String htmlStr = inputString; //含h ...

  8. Windows - Windows的文件名的全路径(Fully Qualified File Name)的最大长度为260字节

    例如,你可以做以下实验来验证这个限制值: 在随意文件夹下新建一个文件夹. 在该新建文件夹下创建一个随意文件.使其名字长度不能再输入为止. 把该文件的全路径名copy到Microsoft Word中进行 ...

  9. VSTO学习笔记(十四)Excel数据透视表与PowerPivot

    原文:VSTO学习笔记(十四)Excel数据透视表与PowerPivot 近期公司内部在做一种通用查询报表,方便人力资源分析.统计数据.由于之前公司系统中有一个类似的查询使用Excel数据透视表完成的 ...

  10. 散文说python半篇——景观三元论与盖茨比的对话

    今天, 天气晴朗,风和日丽: 我事实上在说谎-- 爱说谎事实上是我的天性 上个礼拜四我就用景观三元论说了非常多谎话.然后一头大象自己上吊了. 了不起的大象啊,盖茨比也要从坟墓里爬出来了吧, 陈年旧事, ...