This is a migrated thread and some comments may be shown as answers.

[Solved] Unsupported context type in controller wizard

10 Answers 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 2
Bill asked on 05 May 2011, 01:55 AM

I am getting the above error when trying to add a Controller in my client MVC 3 project.

I have a web service in another project that I'm accessing. This project contains a v4.1 ADO.Net Entity Data Model. Very simple. Six tables in the database. I have already run the web service project and it recognizes the database and customers come up via an OData command in the browser (see below code):

<code>

namespace YeagerTechService
{
public class YeagerTech : DataService<YeagerTechEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("Customers", EntitySetRights.All);
//config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
}

</code>

My client project accesses the web service through a service reference. I am able to put the namespace in my HomeController class (see below code).

<code>

using YeagerTech.YeagerTechService;

</code>

When trying to add a new controller, I just want to display the customers from the Entity Model with a detail view via a Telerik extension (see below code):

Here are the parameters when trying to add the Controller:

ControllerName: CustomerController

Scaffolding Options:

Template: Controller with read/write actions and views, using Entity Framework

Model Class: YeagerTechEntities(YeagerTech.YeagerTechService)

Data Context Class: GridDetailViewItem (Telerik.Web.Mvc.HI.Html)

Views: Razor (CSHTML)

After clicking "Add", that's when i come up with the same exact error...

What is the resolution to this issue?

10 Answers, 1 is accepted

Sort by
0
Bill
Top achievements
Rank 2
answered on 06 May 2011, 01:28 AM
Telerik, any updates on this issue?

If you need me to submit more info, just let me know....
0
Atanas Korchev
Telerik team
answered on 06 May 2011, 06:14 AM
Hi William Yeager,

 This is not supported. Just specifying GridDetailViewItem in the MVC dialog will not generate a grid page for you. The MVCScaffolding has no notion of Telerik Extensions for ASP.NET MVC.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 06 May 2011, 04:56 PM
Atanas, thanks for your reply...

However, how do you then generate a Telerik grid from a controller based on an entity coming from the database? I assumed Telerik would have implanted these extensions into the MVC 3 scaffolding. Is it all manual coding? No scaffolding options at all?

Please let me know if Telerik plans to implement this in the future.

What are we supposed to do now based on this scenario? How do we generated the code for the View? If it is manual, could you supply a short code snippet for an example? If not, what do we supply as an option  as far as what to pick from the drop down list for the scaffolding? Why would the Telerik extensions be in the list if they cannot support the scaffolding?

Thanks a head of time for you answers to these questions....
0
Bill
Top achievements
Rank 2
answered on 07 May 2011, 04:59 PM
Atanas, I understand now that I put the incorrect info in the "Add Controller Wizard", but am still coming up with the same exact error. Attached, you'll see the info I'm putting into the wizard from the available options in the drop down lists.

To back up that I think I'm putting in the correct info, here are some code snippets:

Inside my WCF Data Service where the EDMX model is:
<code>
namespace YeagerTechService
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class YeagerTechEntities : ObjectContext
    {
</code>

<code>
[EdmEntityTypeAttribute(NamespaceName="YeagerTechModel", Name="Customer")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Customer : EntityObject

</code>

I'm just trying to add a new Customer Controller with the "Add New" for the Controllers folder.


What am I doing wrong where the Controller can't get created with the CRUD operations from the wizard. I'm stuck at this point and would appreciate any help.

If you need any more info, I'd be happy to supply it to you.
If you could also answer my previous quetions, that would be great as well.




Thanks so much, bill...
0
Atanas Korchev
Telerik team
answered on 09 May 2011, 06:43 AM
Hi William Yeager,

 I would like again to mention that the MVC scaffolding does not work with Telerik Extensions for ASP.NET MVC. You need to declare the grid in code. A good starting point is our online documentation as well as the online demos.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 09 May 2011, 03:10 PM
Atanas, I understand now about adding the code manually after taking a look at the demos.

However, how does the "Add Controller" wizard know that I want to add a Telerik grid instead of standard MVC CRUD operations? If I want to add a standard form (instead of Telerik) and I pick the same values in the wizard, I need the wizard to be able to create CRUD operations in the new controller.

How can I achieve this?
0
Atanas Korchev
Telerik team
answered on 09 May 2011, 03:20 PM
Hi William Yeager,

 I don't understand the question. Do you mean that the Add Controller wizard automatically picks the grid classes?

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 09 May 2011, 03:27 PM
No... When I didn't have the Telerik extensions installed and I would pick "Add a Controller", using the same input values with the wizard, a controller was generated with CRUD operations.

I was able to do this (Add a Controller), with no problem at all. I don't know if it's because I'm using the Entity Framework in the wizard or not. Before, when I just had my own classes, adding a controller was no issue.

I don't know whether it's because of the Telerik MVC controls installed and or using the Entity Framework in the wizard.

Could you please clarify this for me?
0
Erjan Gavalji
Telerik team
answered on 09 May 2011, 03:48 PM
Hi William,

Basically the Telerik MVC VSExtensions don't interfere with the Add New Controller item template at all. I was not able to reproduce the problem on my side, but I guess I'm missing lots of stuff on my project compared to yours.

The easiest approach to verify if the Telerik MVC VSExtensions cause the problem is to disable them using the Tools -> Extension Manager (VS restart is required after the disabling). Can you check that for me please?

Best regards,
Erjan Gavalji
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 21 Jul 2011, 06:04 PM

I found what the issue is...

I have a 3 tiered architiecture I'm using with each of the below projects in one solution.

  1. YeagerTech
  2. YeagerTechWcfService
  3. YeagerTechModel

No matter what, even though my wcf service references my model, the startup project (1) is not "smart" enough to recognize the metadata to create the Controller. In this case, you must include a reference to your project that includes your edmx model.

You must also ensure that the connectionstring also resides in the startup project (1) via the web.config file, in order to get the connection for the metadata.

Tags
Grid
Asked by
Bill
Top achievements
Rank 2
Answers by
Bill
Top achievements
Rank 2
Atanas Korchev
Telerik team
Erjan Gavalji
Telerik team
Share this question
or