问题描述
我使用的是Windows 8和VS 2012的最终RTM版本。我使用有一个MVC4项目的 SQLCE 4.0与code第一个实体框架模型
I'm using RTM version of Windows 8 and VS 2012 Ultimate. I have a MVC4 project using SqlCe 4.0 with a code first entity framework model.
模式是非常简单的:
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; }
}
当我尝试创建一个新的控制器内置的脚手架嫌我得到以下错误:
When I try to create a new controller with the built in scaffolding too I get the following error:
无法检索MyThing元数据
使用相同的DbCompiledModel创建针对不同的上下文
不支持类型的数据库服务器。相反,创建一个
用于每个类型的服务器单独DbCompiledModel
"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.
我如何获得脚手架工作?
How do I get scaffolding to work?
推荐答案
通过试验和错误,我发现code(它的构造函数的DbContext),导致该错误的行:
By trial and error I found the line of code (it's the DbContext ctor) that is causing the error:
public class MyThingDb : DbContext
{
// If I comment this constructor out the scaffolding works
public MyThingDb()
: base("DefaultConnection")
{
}
public DbSet<MyThing> Things{ get; set; }
}
跆拳道?
这篇关于MVC4脚手架添加控制器给出错误&QUOT;无法检索元数据...&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!