[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. 14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量

    14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量 InnoDB 使用bac ...

  2. dwExStyle和dwStyle的说明(Delphi SDK窗口)

    dwExStyle: :指定窗口的扩展风格.该参数可以是下列值: WS_EX_ACCEPTFILES:指定以该风格创建的窗口接受一个拖拽文件. WS_EX_APPWINDOW:当窗口可见时,将一个顶层 ...

  3. [计算机基础]HTTP协议学习笔记

    HTTP:Hypertext transfer protocol超文本传输协议是一种详细规定了浏览器和Internet之间互相通信的规则 HTTP允许传输任意类型的数据对象,由Content-Type ...

  4. [Android学习笔记]页面布局

    线性布局:LinearLayout 1.集成ViewGroup,故可容纳多个View 2.线性布局,可设置水平或者垂直方向 相对布局:RelativeLayout

  5. PCI 总线学习笔记

    转载请注明出处:http://blog.csdn.net/lg2lh/article/details/8042008 PCI的基本协议这里就不介绍了,由于一般的芯片协议都是集成好的,我仅仅须要大体了解 ...

  6. Android在onInterceptTouchEvent与onTouchEvent

    onInterceptTouchEvent: onInterceptTouchEvent是在ViewGroup里面定义的.Android中的layout布局类一般都是继承此类的.onIntercept ...

  7. 一款新型的智能家居WiFi选择方案——SimpleWiFi在无线智能家居中的应用

    一款新型的智能家居WiFi选择方案——SimpleWiFi在无线智能家居中的应用 先上图:     随着科学技术的不断发展,局域网也正逐渐向无线化,多网合一的方向发展,在这个多网合一快速发展过程中,带 ...

  8. CCEditBox/CCEditBoxImplIOS

    #ifndef __CCEditBoxIMPLIOS_H__ #define __CCEditBoxIMPLIOS_H__ #include "cocos2d.h" #if (CC ...

  9. CoreJava_Collection接口add有一个返回值!

        今天讨论与朋友小知识,我发现很多人不知道collection接口定义add方法返回的值,我们所有的工作很多年Java职工.不熟悉的公共接口,使自己成为在细节上的麻烦.一个小采访这让我想起,当我 ...

  10. Ctrl-A全选

    Ctrl-A全选这点事(C#,WinForm)   所有的文本框,不管单行多行都Ctrl-A全选就好了吧?是啊,很方便.Windows的软件基本都是这样.可为什么我们自己制作的WinForm就默认不是 ...