惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
F
Fortinet All Blogs
B
Blog
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
The Register - Security
The Register - Security
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
B
Blog RSS Feed
WordPress大学
WordPress大学
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
雷峰网
雷峰网
Stack Overflow Blog
Stack Overflow Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Webroot Blog
Webroot Blog
AWS News Blog
AWS News Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
O
OpenAI News
月光博客
月光博客
H
Hacker News: Front Page
S
Security Affairs
W
WeLiveSecurity
The Hacker News
The Hacker News
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
T
The Blog of Author Tim Ferriss
Spread Privacy
Spread Privacy
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
A
About on SuperTechFans

博客园 - 为森

NPM设置镜像 WCF 自托管、无配置文件实现jsonp(跨域)的访问 关于nodejs4.0 npm乱码以及离线全局安装时要注意的问题 C# 正则表达式 转自-每日一bo 关于async & await(TAP)异步模型的异常捕获 一个Public的字段引起的,谈谈继承中的new 解决Bootstrap 附加导航(Affix)的问题和使用时若干注意事项 一次小异常的排查,悲剧的无以复加!!! async & await 小扩展大用处,自己扩展一个ForeachRead吧 转 常用工具和技术 implicit和 explicit关键字 MVC 自定义 以表达式树为参数的htmlhelper 解决解密时出现"要解密的数据的长度无效" 或 "填充无效无法被移除" 的错误 详细说明 配置 Sublime Text 开发node.js(windows)包括sub2和sub3的区别 sql 判断 数据库 表 字段 是否存在 转 WCF中同步和异步通讯总结 关于WCF 解决EF一对一或多对一的删除
EF 的一些不常用的功能
为森 · 2014-08-13 · via 博客园 - 为森

1.Add-Migration Initia-IgnoreChanges 生成已有数据库初始化代码

2.update-database -verbose 升级数据库并显示sql语句

3.Update-Database -Script -SourceMigration:"201309201643300_AddCity.cs" -TargetMigration:"201309201708043_ModifyCity.cs"  这个是生成两次迁移的sql语句,TargetMigration省略是到最新

4.simplemembership的数据库没有migration表 所以迁移的时候如果丢失了迁移类会很麻烦,建议手工修改即可。

5.context的静态构造函数中可以设置数据库初始化器(用于调试)

static PortalContext()
{
    Database.SetInitializer<PortalContext>(null);


//DropCreateDatabaseIfModelChanges
//CreateDatabaseIfNotExists
//DropCreateDatabaseAlways
//MigrateDatabaseToLatestVersion
}

6.Get-Migrations 获取已经应用的迁移

7.Enable-Migrations

在Package Manager Console中执行Enable-Migrations启动迁移。

执行get-help Enable-Migrations –detailed 查看Enable-Migrations的详细用法。

-ContextTypeName 指定要使用的Context

-EnableAutomaticMigrations 启动自动迁移

-ProjectName 指定搭建的迁移类添加到的项目

-StartUpProjectName 指定使用的配置文件所在的项目

-ConnectionStringName 指定使用配置文件中连接字符串的名称

-ConnectionString 指定使用的连接字符串

-ConnectionProviderName 指定连接字符串的provider名称

8.Add-Migration

在Package Manager Console中执行Add-Migration搭建挂起的Model变化迁移脚本。

执行get-help Add-Migration –detailed查看Add-Migration的详细用法。

-Name 指定自定义脚本的名称

-Force

-ProjectName

-StartUpProjectName

-ConfigurationTypeName 指定使用的迁移配置

-IgnoreChanges 忽略检测到挂起的model改变,创建一个空的迁移。这个选项可用来为已有的数据库启用迁移创建一个初始的,空的迁移

-ConnectionStringName 指定使用配置文件中连接字符串的名称

-ConnectionString 指定使用的连接字符串

-ConnectionProviderName 指定连接字符串的provider名称

9.Update-Database

在Package Manager Console中执行Update-Database将挂起的迁移更新到数据库。

执行get-help Update-Database -detailed查看Add-Migration的详细用法。

-SourceMigration 只有-Script打开时才有效。指定迁移的名称用作更新的起点。忽略则使用最后一次应用的迁移。

-TargetMigration 指定将数据库更新到哪个迁移的名称。

-Script 生成SQL脚本

-Force

-ProjectName

-StartProjectName

- ConfigurationTypeName

-ConnectionStringName 指定使用配置文件中连接字符串的名称

-ConnectionString 指定使用的连接字符串

-ConnectionProviderName 指定连接字符串的provider名称