我正在使用 Windows 8 和 VS 2012 Ultimate 的 RTM 版本。我有一个使用 的 MVC4 项目SqlCe 4.0 带代码优先 Entity Framework 模型 .
模型很简单:
public class MyThing
{
public int MyThingId { get; set; }
public int UserId { get; set; }
public string Title { get; set; }
public string Address { get; set; }
public string Description { get; set; }
public DateTime Date { get; set; }
}
当我也尝试使用内置脚手架创建新 Controller 时,我收到以下错误:
"Unable to retrieve metadata for MyThing"
"Using the same DbCompiledModel to create contexts against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.
我如何让脚手架工作?
请您参考如下方法:
通过反复试验,我发现了导致错误的代码行(它是 DbContext ctor):
public class MyThingDb : DbContext
{
// If I comment this constructor out the scaffolding works
public MyThingDb()
: base("DefaultConnection")
{
}
public DbSet<MyThing> Things{ get; set; }
}
跆拳道?