在所选文件中找不到源自DbContext的可构造类型(EF Power Tools Beta 3/Visual Studio 2012) [英] A constructible type deriving from DbContext could not be found in the selected file (EF Power Tools Beta 3/Visual Studio 2012)

查看:59
本文介绍了在所选文件中找不到源自DbContext的可构造类型(EF Power Tools Beta 3/Visual Studio 2012)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将EF Power Tools Beta 3的视图模型"功能用作 序列不包含匹配元素 "的问题.以上文章中的解决方案是可以解决此问题的可接受的解决方法.

我现在遇到第二个错误:

在所选文件中找不到源自DbContext的可构造类型"

在Julie的博客中和解决方案

我过去曾遇到过此问题.当您的上下文做得太多"时,我故意留下模糊的评论.但是您通常可以将其范围缩小到您的构造函数代码.

如果由于构造函数参数而使powertool无法轻松实例化您的上下文,或者构造函数启动了power station,则该工具将放弃...毫无疑问,关于无参数构造函数的技术分析更多,但您将了解很多可以避免的知识.我使用了注释掉的VANILLA构造函数,该构造函数用于生成视图.完成工作后再放回去.;-)

 公共类MyFANCYDbContext:DbContext {MyFANCYDbContext(此处是什么?EF电动工具可以提供吗?){在构造函数内部...我要启动电站吗?任何其他问题阻止创建对象MyFancyDbContent成功?}} 

尝试引用App.config中的VALID条目的简单构造函数.

I'm trying to use the "View Model" feature of the EF Power Tools Beta 3 as heavily depended on by Julie Lerman within Visual Studio 2012.

I originally had the "sequence contains no matching element" problem many people seem to have encountered. The solution in the above article is an acceptable workaround that fixes the problem.

I'm now encountering the second error:

"A constructible type deriving from DbContext could not be found in the selected file"

The proposed cause of the problem in Julie's blog and in this question is that there is a conflicting extension somewhere.

I have disabled all possible extensions, yet I'm still receiving the error.

Is there any more information on how to resolve this?

Alternatively, I'm also using VS2013 Preview. Is this (working) functionality available in this version of Visual Studio?

解决方案

I have had this issue in the past. It comes when your Context, "does too much" I left that comment deliberately vague. But you can generally narrow it down to your constructor code.

If the powertool cant easily instantiate your context due to constructor params or the constructor starts up power station, the tool gives up... There is no doubt a more technical analysis around parameter-less constructors but you will know enough to avoid. I use commented out VANILLA constructor that I use for view generation purposes. Then put it back when done for live work. ;-)

public class MyFANCYDbContext : DbContext  {
   MyFANCYDbContext( what is here??? Can EF powertool supply this ?){

     Inside the Constructor... do I start a power station ? Any other issues
        preventing the Create object  MyFancyDbContent from succeeding ?   
  }
}

EDIT: try the simple constructor that refers to a VALID entry in App.config.

这篇关于在所选文件中找不到源自DbContext的可构造类型(EF Power Tools Beta 3/Visual Studio 2012)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆