Dynamic Data Templates in VS 2008

The Dynamic Data templates option in VS 2008 can be a bit confusing so here is an overview.

The “Dynamic Data Entities Web Site” template create an empty Entity Framework project and you use Add -> New -> ADO.NET Entity Data Model to add your data model to the project. The Dynamic Data routing is configured in the global.asax file.

If you want to control how Dynamic Data creates the UI and validates data input then add a new class using the System.ComponentModel.DataAnnotations name space. Example below

[MetadataType(typeof(Account_Metadata))]
public partial class Account
{
}

public partial class Account_Metadata
{

[ScaffoldColumn(false)]
public object UpdateDate { get; set; }

[StringLength(30)]
[Required(ErrorMessage = “Account name is required.”)]
public object Description { get; set; }

The “Dynamic Data Web Site Wizard” template creates a Linq to Sql based project and the wizard guides you through the creation of the dd web site. As part of this you will get an option to create specific input forms for each entity.

It automatically creates a class named file YourModelDataContext.partial.cs which contains all the MetaData classes.

The routing info is in the class DynamicData.cs

Leave a Reply

Your email address will not be published. Required fields are marked *