我正在使用RTM版本的Windows 8和VS 2012 Ultimate。我有一个MVC4项目使用SqlCe 4.0与代码第一实体框架模型。
型号很简单:
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; } }
当我尝试用内置的脚手架创建一个新的控制器,我得到以下错误:
“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; } }
WTF?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。