What is ASP.NET Dynamic Data

ASP.NET Dynamic Data is a new web application framework from Microsoft. Dynamic Data allows developers to quickly build web sites. Dynamic Data takes care of coding the daily grind CRUD operations including validation, data relationship management, data type management and UI display templates. All this is based on your database schema (via a data model such as LINQ to SQL or Entity Framework). This leaves room for you to focus on business logic, application modeling and other requirements, rather than things like “glue code” for CRUD and UI validation.

When you create an ASP.NET Dynamic Data web application, you are templating the application for dynamic access via the data model. There are two main types of templates, page and field level. The page level templates use a routing system to map the URL to the data model so it can populate controls such as a GridView or DetailsView dynamically. The field level templates are web user controls (.ascx) that match data types in the data model. Together, the field and page templates dynamically create pages for viewing, editing/inserting and other functionality.

ASP.NET Dynamic Data emphasizes a few concepts: convention over configuration, DRY (don’t repeat yourself) and SOC (separation of concerns). The combination of these principles plus the built in plumbing means a faster to market, easier to maintain web application.

What Dynamic Data Isn’t

Dynamic Data isn’t code generation. Templates are created that you can use out of the box for a complete card carrying CRUD site.

Dynamic Data isn’t just scaffolding, it can be used to create administrative back-ends but can also be used for more heavy lifting and public facing sites, due to its ease of extensibility.

Site Structure, a quick look:

When you create an ASP.NET DD site, here’s what you get:

ddfiles

As you can see, this is just regular web application, except a new folder \DynamicData has been created. Under this folder, page and field templates are define in the \PageTemplates and \FieldTemplates folders respectively. This is ASP.NET Dynamic Data’s plumbing, and where all the dynamic work gets done.

You’ll also notice the App_Code folder contains a LINQ to SQL data model. When a URL for this application is requested in the form of /{table}/{action} (e.g., /products/list.aspx), Dynamic Data maps the table to the corresponding entity and fills the dynamic controls on the requested page, so /products/list.aspx would render all the data from products table using the List.aspx page located in the \PageTemplates folder as would /categories/list.aspx do the same thing using the same page, but category data would display instead. This routing mechanism helps enforce the DRY principle, as you don’t need to keep creating pages for each entity, just one page template will do.

The Dynamic output

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Browsing the URL <app root>/products/list.aspx displays the output below. Data that is mapped to elements defined in the field and page templates will be displayed on the list.aspx page.

sample_page

Summary

ASP.NET Dynamic Data gives you a flexible system to be able to rapidly create flexible websites that can take advantage of DRY, SOC and and COC.