我的所有搜索都回到了两个问题中的同一个问题,这不是本项目中的问题.我之前从未遇到过这方面的麻烦,但这个特别的项目很奇怪.
首先,项目名称是Site.该类SiteContext继承DbContext.
当我运行Enable-Migrations时,即使是显式的,包管理器控制台也会返回错误:
PM> Enable-Migrations -ContextType SiteContext
The context type 'SiteContext' was not found in the assembly 'Site'.
Run Code Online (Sandbox Code Playgroud)
但它在代码中就是这样:
// Not in a namespace or anything
public class SiteContext : DbContext {
// public DbSets in here
}
Run Code Online (Sandbox Code Playgroud)
我可以SiteContext在我的站点代码中的任何地方使用,通过它的对象访问数据库等等.它只是无法找到它的Enable-Migrations命令.除此之外,Entity的代码优先功能正常运行.
可能会发生什么想法?我在哪里搞砸了?
(实体框架6.0.2 /网页3.1.1)