views:

268

answers:

4

I've added in the Dynamic Data stuff to our existing website, and gotten that working as far as adding a DynamicDataManager to a page and setting a GridView to use it. However I think I'd like to get the full scaffolding functionality up and running so I don't have to write all the layouts for all the tables. Unfortunately I can't get it to work.

I've added code to Application_start() to register the data context and set up the route. I've tried with both "{table}/ListDetails.aspx" and "{table}/{action}.aspx" versions but I only get an HTTP 404 error. I also have ScaffoldAllTables set to true.

Am I missing a step or two here?

Here is my application start code:

protected void Application_Start(Object sender, EventArgs e)
     {


            RegisterRoutes(RouteTable.Routes);

     }


public static void RegisterRoutes(RouteCollection routes)
        {
            MetaModel model = new MetaModel();


            model.RegisterContext(typeof(ESLinqDataContext), new ContextConfiguration() { ScaffoldAllTables = true });


            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.List,
                ViewName = "ListDetails",
                Model = model
            });

            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.Details,
                ViewName = "ListDetails",
                Model = model
            });
        }
A: 

Did you add this in your global.asax

model.RegisterContext(typeof(AdventureWorksLT_DataModel.AdventureWorksLT_DataEntities), 
new ContextConfiguration() { ScaffoldAllTables = true });

http://msdn.microsoft.com/en-us/library/cc488469.aspx has a step by step walkthrough..see if you missed any.

CodeToGlory
In the above article, please check the first comment about deleting the app_code folder and putting the dbml file in the root to gain access to DataContext.
CodeToGlory
The dbml file is in a dll file... do I have to do something special for that?
Telos
A: 

Could you show your Application_start() code? And which version of IIS are you using?

A good explanation of adding Dynamic Data to an existing website can be found on Scott Hanselman's website: http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx

Michael
Version 5.1 of IIS, but I'm running it through visual studio... will post the app_start in a sec
Telos
I don't think it's an IIS problem... I set up a quick Dynamic Data Web Application and it's working fine through Visual Studio.
Telos
+1  A: 

I needed to add

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, publicKeyToken=31BF3856AD364E35" />

to the httmodules section of my web.config.

Telos
OK. Glad to see you found the solution. :-)
Michael
A: 

see:

Walkthrough: Adding Dynamic Data to an Existing Web Site

Scott Hunter : How to add Dynamic Data to an Existing Web Site

All the requirement s are there for getting DD working in a existing website.

Wizzard