Turn off DB Initializer in Code-First:

You can also turn off the DB initializer of your application. Suppose, for the production environment, you don't want to lose existing data, then you can turn off the initializer, as shown in the following:

public class SchoolDBContext: DbContext
{
public SchoolDBContext() : base("SchoolDBConnectionString")
{
//Disable initializer
Database.SetInitializer<SchoolDBContext>(null);
}
public DbSet<Student> Students { get; set; }
public DbSet<Standard> Standards { get; set; }
}

You can also turn off the initializer in the configuration file, for example:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DatabaseInitializerForType SchoolDataLayer.SchoolDBContext, SchoolDataLayer"
value="Disabled" />
</appSettings>
</configuration>

最新文章

  1. WPF数据编辑的提交与撤销
  2. Ubuntu12.04卡死的解决方案
  3. (转)NoSQL系列:选择合适的数据库
  4. ASP.NET MVC 实现与SQLSERVER的依赖缓存
  5. PHP用户登录与注册页面
  6. kafka web console安装
  7. OracleServiceORCL服务不见了怎么办
  8. 实战开发-》融云tp3.2.3
  9. MSIL实用指南-生成if...else...语句
  10. web 项目运用通用的xml配置
  11. todo项目总结
  12. pyspider 启动错误遇到的一些坑
  13. go.cd 自动化构建
  14. mysql 5.7 修改字符编码
  15. 深入浅出的webpack构建工具---HappyPack优化构建(九)
  16. BZOJ1251序列终结者——非旋转treap
  17. 代码控制打电话、发短信、发邮件、打开手机app等操作
  18. PageUtil 分页
  19. jquery完全版下载
  20. C# SqlConnection连接sql server

热门文章

  1. ios开发小技巧(转)
  2. Arc066_F Contest with Drinks Hard
  3. centos 下配置oracle11gR2开机自启
  4. 【LeetCode】008. String to Integer (atoi)
  5. hashmap&amp;linkedlist
  6. linux下ioctl遇到的坑
  7. [转]Cache-Control max-age=0
  8. NuGet学习笔记(2)——vs2015搭建本地NuGet服务器
  9. MySQL 双主+keepalived 详细文档 M-M+keepalived
  10. vue-cli脚手架build目录中的karma.conf.js配置文件