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

问题描述

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

采取的措施:

1.增加了通过模型右击并加入LINQ to SQL类:新模式
2.拖从服务器资源管理表到我的新的dbml布局和保存

3.右键单击Controllers->添加 - >控制器

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:

控制器名称: UserController的

  模板:控制器具有读/写操作和视图,使用实体框架

  模型类: aspnet_User(TierPay)

  数据上下文类: AgricultureDataContext(TierPay)

  查看:剃须刀(VBHTML)

5.Click添加

6.Get以下错误:

不支持的上下文类型。

5.Click Add
6.Get the following error:
Unsupported context type.

我周围的一派,都没有找到任何答案。
谢谢!

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