本文介绍了MVC3添加控制器脚手架错误 - 不支持的上下文类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个新的MVC 3应用程序。

采取的步骤:

1.通过右键单击模型并添加LINQ to SQL类添加新模型>
2.将表从服务器资源管理器拖动到我的新dbml布局并保存

3.右键单击Controllers-> Add-> Controller

4.输入以下内容信息:

I'm creating a new MVC 3 application.
Steps taken:
1. Added new model by right clicking on Models and adding "LINQ to SQL Classes"
2. Dragged tables from Server Explorer to my new dbml layout and saved
3. Right click on Controllers->Add->Controller
4. Enter the following information:

5.点击添加

6.获取以下错误:

不支持的上下文类型。

我已经搜索过,没有找到任何答案。
谢谢!

I've Googled around and haven't found any answers.Thanks!

推荐答案

当使用实体数据模型而不是Linq到SQL时,我得到这个错误。我已经从现有的SQL Server数据库创建了模型。该问题是由在添加控制器对话框中选择错误的数据上下文类导致的。该值需要是顶级类,在我的情况下,Entitites作为名称的一部分。我希望这有助于。

I was getting this error when working with the Entity Data Model instead of Linq to SQL. I had created the model from an existing SQL Server database. The problem was caused by selecting the wrong Data Context Class in the Add Controller dialog. That values needs to be the top level class, in my case the one with "Entitites" as part of the name. I hope this helps.

这篇关于MVC3添加控制器脚手架错误 - 不支持的上下文类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:28