MVC3 Add Controller Scaffolding Error - Unsupported Context Type

fhilton picture fhilton · Feb 2, 2012 · Viewed 14.9k times · Source

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:

Controller name: UserController
Template: Controller with read/write actions and views, using Entity Framework
Model Class: aspnet_User (TierPay)
Data Context Class: AgricultureDataContext (TierPay)
Views: Razor (VBHTML)

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

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

Answer

Ken Mc picture Ken Mc · May 30, 2012

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.

Add new Controller to MVC project From Entity Models