【发布时间】:2014-04-08 14:50:05
【问题描述】:
我所有的搜索都返回到两个问题中的同一个,这不是这个项目的问题。我以前从来没有遇到过这个问题,但是这个特殊的项目很奇怪。
首先,项目名称是Site。 SiteContext 类继承 DbContext。
当我运行 Enable-Migrations 时,即使是显式地,包管理器控制台也会返回错误:
PM> Enable-Migrations -ContextType SiteContext
The context type 'SiteContext' was not found in the assembly 'Site'.
但它就在代码中:
// Not in a namespace or anything
public class SiteContext : DbContext {
// public DbSets in here
}
我可以在我的站点代码中的任何位置使用SiteContext,通过它的对象访问数据库等。只有 Enable-Migrations 命令找不到它。除此之外,Entity 的代码优先功能正常工作。
任何想法可能会发生什么?我在哪里搞砸了?
(实体框架 6.0.2 / 网页 3.1.1)
【问题讨论】:
-
它与 ASP.NET (Web Forms) 有什么关系?如果不是,请编辑您的问题以将其从标题中删除 (which is not the proper place for tags)。
-
@abatishchev 首先,Web Pages 与 Web Forms 完全不同。其次,提到网页表明我没有使用 MVC,这是 ASP.NET 的默认假设。既然你是对的,这可能对问题并不重要,我已经删除了它。
-
是的,抱歉,这是一个错字。我不能同意 ASP.NET = MVC。这绝对是不正确的,而不是 StackOverflow 上发生的事情。感谢您编辑您的问题。干杯!
标签: c# asp.net entity-framework asp.net-webpages