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

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - tubo

依赖Asp.net Core的类库 找一款可以插入数学公式的思维导图软件 联想个人云开启Docker并安装常用的Docker 联想个人云无损开启SSH 我只想在Windows Server 2019上build 基于Linux的Docker Gerrit 添加用户 Windows 10 安装过程中,在自定义登录页面进入审核模式 mac远程桌面连接windows 8.1 update,提示: 远程桌面连接无法验证您希望连接的计算机的身份 iOS开发点滴:iPhone屏幕适配 C# Winform中如何让PictureBox的背景透明 ExtJS扩展:扩展grid之toolbar button禁用表达式 ExtJS扩展:扩展grid Extjs扩展:封装Plupload 用NuGet管理程序包时,如果解决方案目录下的packages文件夹中某一个程序包存在2个以上的版本,则会提示错误 User Profile Service服务未登录,无法加载用户配置文件 可动态构造查询条件的表达式类库(1) Windows 8安装杀毒软件avast后,不能用Sysprep进行通用化封装 “PostSharp21”任务意外失败 为什么TFS会自动签出解决方案文件(.sln)?
Nuget 启用数据库迁移的时候一定要把包含DbContext的项目设为启动项目
tubo · 2012-10-05 · via 博客园 - tubo

在为项目启用数据库迁移的时候(enable-migrations)出现如下错误:

在程序集“XX”中未找到迁移配置类型“XX.Migrations.Configuration”

之前一直正确的,并没有修改项目中的代码,花了小半天找原因,stackoverflow和一些国外的网站都有类似错误,但是我这个不是

http://www.ideablade.com/forum/forum_posts.asp?TID=3611&title=code-first-migration

http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/39edecbf-267d-4e88-bad9-87c60f330d8a

这篇文章中说要在Nuget控制台中选择正确的项目,我也选择了正确的项目,但是还是继续出现错误。

我尝试修改DbContext的命名空间,再次运行enable-migrations,令人不解的现象出现了,自动生成的迁移配置文件中的DbContext类的命名空间并没有发生变化,还是原来的命名空间,看来enable-migrations并没有使用当前我选择的项目的最新生成的程序集,查找了硬盘上所有该项目生成的程序集,发现新加入到解决方案的一个web项目(该web项目设置为启动项目)文件夹下的包含DbContext程序集的日期是比较老的日期,就是还没有启用数据库迁移的版本。到这里明白了enable-migrations是从启动项目里面去找包含DbContext的程序集的……

我新加入一个web项目,理所当然把它设置成了启动项目,enable-migrations执行的时候会先编译,这个时候我的DbContext程序集里面还没有迁移配置的任何代码,编译之后会在包含DbContext这个项目里面添加迁移配置代码,但是这个时候web项目引用的那个程序集里面还是没有迁移配置的任何代码,所以出现了上面的错误。

把启动项设置成包含DbContext的项目,问题解决。

NuGet的enable-migrations为什么会找启动项目,而不是用我在nuget控制台中选择的项目呢?