Dynamic Data Entities Web Application

When you opened up your Visual Studio 2008, you may have seen the ASP.net News on the Start Page promoting Joe Stagner's Six New Videos on ASP.NET Dynamic Data.

I viewed each one with interest and thought I'd do a bit more research on the topic. Some questions came to my mind, such as: Which Dynamic Data project/website do I build? An Entities or a LINQ to SQL?

It appears the answer to that is Entities. Based on Microsoft's post Update on LINQ to SQL and LINQ to Entities Roadmap, it may appear that LINQ to SQL is already becoming obsolete. This strongly worded post indicates that LINQ to SQL is Dead, killed by Microsoft. In answer, a Microsoft member of the LINQ to SQL team responds in LINQ to SQL Next Steps.

Okay, that decided, I went with the Dynamic Data Entities application.

The next question I encountered was, is this really something to be used for a full-blown web application with the bells and whistles? Sidebars, menus, professional-looking forms, etc.? Seriously, it looked to me like an admin tool I might use to populate helper tables and not something to be used for a full-blown professional web application.

David Hayden says "Out-of-the-box it can provide admin pages for your database tables, but with a little imagination you can do so much more than that. " Here is another post that clarifies Dynamic Data Entities Websites - EntityDataSource and ASP.NET Website Scaffolding - Rapid Application Development ( RAD ). Here are numerous other dynamic data posts from the same author, David Hayden.

In ASP.NET 3.5 SP1 Dynamic Data, Eric Moreau indicates "I would say that it builds great data-driven web site to administer your data without requiring much coding if you are ready to accept default behaviours." 

Now, I've viewed numerous videos on this topic, including David Ebbo's most excellent, Developing Data Driven Applications Using ASP.NET Dynamic Data Controls and the MSDN Webcast: geekSpeak: ASP.NET Dynamic Data with Rachel Appel, but if you want to actually follow step by step instructions with images on how to setup one of these applications, I highly recommend Eric Moreau's post, even though it is LINQ to SQL.

http://msdn.microsoft.com/en-us/library/cc488546.aspx
Topics include:
Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding.
How to: Customize ASP.NET Dynamic Data Default Field Templates
How to: Customize Data Field Appearance and Behavior in the Data Model
How to: Customize the Layout of an Individual Table By Using a Custom Page Template
How to: Customize Data Field Validation in the Data Model.
How to: Add Dynamic Behavior to Data-Bound Controls by Using a DynamicField.
How to: Use ASP.NET Dynamic Data in Templated Data-Bound Controls.

Now a potential problem is, what if you have a need for a Many to Many relation? LINQ to SQL version evidentally won't handle that. David Ebbo shares with us A ‘Many To Many’ field template for Dynamic Data, which adds a ManyToMany.ascx and AutoFieldGenerator class to allow using checkboxes on edit to select multiple fields from another table. This is in C#.

Another post, Many to Many FieldTemplates with Dynamic Data and Entity Framework, also shares source code on how to do this. Another author shares "I have modified the standard page templates though for being more user-friendly (like having the parent set automatically in the dropdown when inserting a new item going from parent details) and also have implemented a generic many-to-many editor (two actually, one with two listboxes and move left/right) and one with a checkboxlist, pretty simple although you have to use reflection."

There currently is also a problem with the framework in that it may generate an error like "'System.Web.UI.WebControls.EntityDataSourceWrapper' does not contain a property with the name 'Orders.OrderID'" due to foreign key relations. This post, Dynamic Data Entity Framework Workaround, you add a dll in your bin folder for websites, or add a reference for web applications, make a few changes to your code and voila, this problem is also fixed.

The above fix is in C#. The VB version of this fix is:

model.RegisterContext(New Microsoft.Web.DynamicData.EFDataModelProvider(GetType(MyEntities)), New ContextConfiguration() With {.ScaffoldAllTables = True})

and

    Protected Function GetDisplayString() As String
        Try
            Return FormatFieldValue(ForeignKeyColumn.ParentTable.GetDisplayString(FieldValue))
        Catch ex As Exception
            Return ForeignKeyColumn.ParentTable.DisplayName
        End Try
    End Function

If you want to read further about what this is, try Introduction to ASP.NET Dynamic Data. There is also a Dynamic Data Forum. 

Also, check out the MSDN Virtual Lab: Developing ASP.NET Dynamic Data lab. See more Virtual Labs.

Here is some older reading: ASP.NET Dynamic Data Applications. It uses the preview versions of the Dynamic Data, rather than the 3.5 SP1.

For info on ASP.NET Dynamic Data Filtering, check out this article which also recommends these additional links.

What about Images in Dynamic Data Websites? Check out How to: Display Images in an Existing ASP.NET Dynamic Data Web Site.

If you use Telerik's RADControls, as do I, you'll want to check out these blogs:

RadControls and ASP.NET Dynamic Data

So in short, if you want to throw together some quick admin tools to populate your tables while you spend more time building an imaginative user interface, this is a great tool. As well, I expect to give it a shot with some of that "Imagination" that David Hayden speaks of.

Let me know what you've done with it. Have you created a web application with it? Have you used it out-of-the-box? What types of projects have you used it on. I'd love to hear your feedback!

May your dreams be in ASP.NET!

Nannette

 

 

 

 

 

 

 

 

3 Comments

  • thanks for all the informations.. it was very useful..

  • Seen lots of video tutorials on L2S Dynamic Data but not on Dynamic Data Entities. Any hints?

  • Help... am very confused... I want to learn this EDM thing, but too many links and forums... information overload here.... I also saw this ASP.NET dynamic data entities web application when i try to create a new project, is this different with an ASP.Net Web application?

    If am going to create a web app and having a WCF, Web App and this EDM. what proj apps should i create?

    Many thanks!

Comments have been disabled for this content.