<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Marcin On ASP.NET : metadata</title><link>http://blogs.msdn.com/marcinon/archive/tags/metadata/default.aspx</link><description>Tags: metadata</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Dynamic Data samples: Custom metadata providers</title><link>http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples-custom-metadata-providers.aspx</link><pubDate>Fri, 23 May 2008 02:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8535066</guid><dc:creator>marcind</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/marcinon/comments/8535066.aspx</comments><wfw:commentRss>http://blogs.msdn.com/marcinon/commentrss.aspx?PostID=8535066</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;6/25 Update:&lt;/STRONG&gt; This sample has become part of the &lt;A class="" href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475" mce_href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475"&gt;Dynamic Data Futures&lt;/A&gt; project on codeplex. You can still use this code but you should check out the Futures project as it contains a lot more. The key conecpts are the same, though some names or APIs might have changed.&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Note&lt;/I&gt;: This post is part of a series, see the list of other &lt;A href="http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples.aspx" mce_href="http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples.aspx"&gt;Dynamic Data samples&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;A while back I posted some &lt;A href="http://blogs.msdn.com/marcinon/archive/2007/12/10/adding-custom-metadata-providers-in-asp-net-3-5-extensions-preview.aspx" mce_href="http://blogs.msdn.com/marcinon/archive/2007/12/10/adding-custom-metadata-providers-in-asp-net-3-5-extensions-preview.aspx"&gt;sample code for adding custom metadata providers&lt;/A&gt;. Since then much has changed in the Dynamic Data runtime and it is time to post an updated version. This sample illustrates how to write a custom metadata provider that allows you to programmatically add metadata attributes to an in-memory store before you register your model with the Dynamic Data runtime in Global.asax.&lt;/P&gt;
&lt;P&gt;This sample should work with the &lt;A href="http://code.msdn.microsoft.com/dynamicdata" mce_href="http://code.msdn.microsoft.com/dynamicdata"&gt;latest preview release of Dynamic Data&lt;/A&gt;.&lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Running the sample&lt;/H3&gt;
&lt;P&gt;Download the &lt;A class="" href="http://blogs.msdn.com/marcinon/attachment/8535066.ashx" mce_href="http://blogs.msdn.com/marcinon/attachment/8535066.ashx"&gt;metadata provider sample&lt;/A&gt; solution, extract to your preferred location, and open in Visual Studio 2008 SP1. The solution contains two projects: a sample website and a small library project that contains the metadata provider code.&lt;/P&gt;
&lt;P&gt;Run the included website and go the Products list page. Once there hit Edit on any of the rows. You will be taken to a details view for the row you are editing. Change the UnitsInStock field to a negative value and move out of the field: a range validation error appears. Go back to the same field, clear it, and move out again: a required validation error appears.&lt;/P&gt;
&lt;H3&gt;How it works&lt;/H3&gt;
&lt;P&gt;The website scaffolds a small subset of the Northwind sample database. The UnitsInStock column on the Product table is decorated with two attributes: RequiredAttribute and RangeAttribute. However, the unique thing here is that each attribute is coming from a different source.&lt;/P&gt;
&lt;P&gt;The RequiredAttribute is declared in the default Dynamic Data way using a metadata proxy class:&lt;/P&gt;&lt;PRE class=code&gt;[&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;MetadataType&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Product_MD&lt;/SPAN&gt;))]&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;public partial class &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Product &lt;/SPAN&gt;{&lt;BR&gt;&lt;BR&gt;    &lt;SPAN style="COLOR: blue"&gt;private class &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Product_MD &lt;/SPAN&gt;{&lt;BR&gt;        [&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Required&lt;/SPAN&gt;(ErrorMessage=&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"This field is required [from MetadataType]"&lt;/SPAN&gt;)]&lt;BR&gt;        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;UnitsInStock { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }&lt;BR&gt;    }&lt;BR&gt;}&lt;/PRE&gt;
&lt;P&gt;The RangeAttribute is added to the InMemoryMetadataManager class in Global.asax:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;InMemoryMetadataManager&lt;/SPAN&gt;.AddColumnAttributes&amp;lt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Product&lt;/SPAN&gt;&amp;gt;(p =&amp;gt; p.UnitsInStock,&lt;BR&gt;    &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;RangeAttribute&lt;/SPAN&gt;(0, 1000) { &lt;BR&gt;        ErrorMessage = &lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"This field must be between {1} and {2} [from InMemeroyMetadataManager]." &lt;/SPAN&gt;}&lt;BR&gt;);&lt;/PRE&gt;
&lt;P&gt;The AddColumnAttributes function shown here has a way to strongly type the property references (as opposed to writing something like AddColumnAttributes("UnitsInStock", ...)) using a simple lambda expression. This provides for some nice IntelliSense support that would not be available if you were referring to properties using simple strings.&lt;/P&gt;
&lt;P&gt;In order to have the Dynamic Data runtime pick up the metadata attributes added to InMemoryMetadataManager you need to modify your model registration call in Global.asax:&lt;/P&gt;&lt;PRE class=code&gt;model.RegisterContext(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;NorthwindDataContext&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;ContextConfiguration&lt;/SPAN&gt;() {&lt;BR&gt;    ScaffoldAllTables = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;,&lt;BR&gt;    MetadataProviderFactory =&lt;BR&gt;        (type =&amp;gt; &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;InMemoryMetadataTypeDescriptionProvider&lt;/SPAN&gt;(type, &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;AssociatedMetadataTypeTypeDescriptionProvider&lt;/SPAN&gt;(type)))&lt;BR&gt;});&lt;/PRE&gt;
&lt;P&gt;The MetadataProviderFactory&amp;nbsp;property of ContextConfiguration lets you specify a metadata provider factory method that is used by the Dynamic Data runtime to obtain an instance of a &lt;A href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typedescriptionprovider.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typedescriptionprovider.aspx"&gt;TypeDescriptionProvider&lt;/A&gt; that acts as the source of metadata attributes for a given table (type). The sample above also illustrates TypeDescriptionProvider chaining, which is what supports the fact that the table receives metadata from two sources: the InMemory provider adds its metadata to the results returned by the AssociatedMetadataType provider and returns a combined collection.&lt;/P&gt;
&lt;H3&gt;Truly dynamic metadata&lt;/H3&gt;
&lt;P&gt;At this point it is tempting to consider a dynamic metadata provider that would let you add, remove, and modify attributes throughout the lifetime of the application and not just during the application's startup phase. For example, you could imagine having&amp;nbsp;some sort of administrative interface that would let you turn on and off whether a field is required or modify its description, even after the model has already been registered.&lt;/P&gt;
&lt;P&gt;While it would seem that such a scenario would require minimal changes to the InMemoryMetadataManager class there is one detail about Dynamic Data that makes this a lot more complicated: the current Dynamic Data runtime fetches the metadata upon model registration and then caches it inernally for the lifetime of the app domain. This means that any changes that you make to the metadata through InMemoryMetadataManager after the model has been registered will be ignored.&lt;/P&gt;
&lt;P&gt;This is a limitation of Dynamic Data that we will address in future versions. For the time being the only way to get around this would be to &lt;A href="http://msdn.microsoft.com/en-us/library/system.web.httpruntime.unloadappdomain.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.httpruntime.unloadappdomain.aspx"&gt;unload the app domain&lt;/A&gt;. However, this is means that you will need to find a place (such as a database) to store the new metadata while the app restarts.&lt;/P&gt;
&lt;H3&gt;What about the XML metadata?&lt;/H3&gt;
&lt;P&gt;My old custom metadata provider sample had an implementation of an XML-based metadata provider but the current one does not. The reason for this is that since the December CTP we have added support for even more attributes and some of the attributes have become a lot more complex. Because much of the old sample had to do with deserializing CLR attributes from an XML representation instead of anything specific to Dynamic Data I decided not to develop the old XML provider any further. However, if somebody ever wrote the appropriate XML parsing code it could easily be used to populate the InMemoryMetadataManager with the right values, essentially resulting in an XML metadata provider. Just remember about the domain unloading mentioned earlier.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8535066" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/marcinon/attachment/8535066.ashx" length="869249" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/marcinon/archive/tags/metadata/default.aspx">metadata</category><category domain="http://blogs.msdn.com/marcinon/archive/tags/ASP.NET+Dynamic+Data/default.aspx">ASP.NET Dynamic Data</category><category domain="http://blogs.msdn.com/marcinon/archive/tags/samples/default.aspx">samples</category></item><item><title>Adding custom metadata providers in ASP.NET 3.5 Extensions Preview</title><link>http://blogs.msdn.com/marcinon/archive/2007/12/10/adding-custom-metadata-providers-in-asp-net-3-5-extensions-preview.aspx</link><pubDate>Tue, 11 Dec 2007 04:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6726671</guid><dc:creator>marcind</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/marcinon/comments/6726671.aspx</comments><wfw:commentRss>http://blogs.msdn.com/marcinon/commentrss.aspx?PostID=6726671</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;5/22/08 Note:&lt;/STRONG&gt;&amp;nbsp;this post talks about an outdated ASP.NET release. Please have a look at this &lt;A class="" href="http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples-custom-metadata-providers.aspx" mce_href="http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples-custom-metadata-providers.aspx"&gt;updated dynamic metadata provider sample&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;One of the most powerful elements of the new ASP.NET Dynamic Data feature we are working on is the ability to associate metadata (for example, range validation or formatting) with your data model. You can then query the model and use the provided information to customize the processing of your data. In the recently released &lt;A href="http://asp.net/downloads/3.5-extensions/" mce_href="http://asp.net/downloads/3.5-extensions/"&gt;ASP.NET 3.5 Extensions Preview&lt;/A&gt; this annotation is done by declaring special metadata attributes on the partial classes representing the entities in the model. The &lt;A href="http://quickstarts.asp.net/3-5-extensions/dyndata/ValidationUsingDataModelAttributes.aspx" mce_href="http://quickstarts.asp.net/3-5-extensions/dyndata/ValidationUsingDataModelAttributes.aspx"&gt;initial implementation&lt;/A&gt; is a bit limited, however, because the metadata association can only be done using CLR attributes and those attributes have to be declared on the class (even if they pertain to the class's properties):&lt;/P&gt;&lt;PRE class=code&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;Range&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"Quantity"&lt;/SPAN&gt;, 0, 10000)] &lt;BR&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;Range&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"Price"&lt;/SPAN&gt;, 0, 20000)] &lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;partial class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Product &lt;/SPAN&gt;{ &lt;BR&gt;}&lt;/PRE&gt;
&lt;H3&gt;A better approach&lt;/H3&gt;
&lt;P&gt;The MVC Toolkit (which incorporates a number of modifications to the Preview that will be included in later milestones – &lt;A title="MVC Toolkit files" href="http://asp.net/downloads/3.5-extensions/MVCToolkit.zip" target=_blank mce_href="http://asp.net/downloads/3.5-extensions/MVCToolkit.zip"&gt;download here&lt;/A&gt;) contains an alternative implementation. This implementation has the following improvements:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A pluggable metadata model based on providers. &lt;/LI&gt;
&lt;LI&gt;New metadata attributes that can be declared on the properties of a special metadata "buddy" class. &lt;/LI&gt;
&lt;LI&gt;An alternative reference provider implementation based on XML files. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The best way to familiarize yourself with the new model is to look at the samples included with the MVC toolkit. However, here are a few points to get you started:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The registration of a metadata handler is done on a DataContext type using the MetadataHandlerRegistration class. This needs to be done only once per application, for example in the Global.asax file: &lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;protected void &lt;/SPAN&gt;Application_Start(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs &lt;/SPAN&gt;e) {
&lt;SPAN style="COLOR: #2b91af"&gt;&lt;FONT color=#333333&gt;    &lt;/FONT&gt;MetadataHandlerRegistration&lt;/SPAN&gt;.Register(&lt;BR&gt;        &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;MyDataContext&lt;/SPAN&gt;), &lt;BR&gt;        &lt;SPAN style="COLOR: #2b91af"&gt;MetadataHandlerRegistration&lt;/SPAN&gt;.XmlMetadataProvider);
}&lt;/PRE&gt;&lt;B&gt;Note:&lt;/B&gt; Only Linq to SQL models are supported in this version. Future releases will support both Linq to SQL and ADO.NET Entities. &lt;/LI&gt;
&lt;LI&gt;MetadataHandlerRegistration contains references to 2 different metadata providers: buddy class-based and XML file-based. &lt;/LI&gt;&lt;/OL&gt;
&lt;H3&gt;Buddy class metadata&lt;/H3&gt;
&lt;P&gt;Buddy class metadata is a model in which you associate a "buddy class" with your actual data model class and declare the metadata attributes on properties of the buddy class. "Why do I need to declare a parallel class?", you ask. The simple answer is that the current versions of C# and VB have no concept of partial properties.&lt;/P&gt;
&lt;P&gt;This implementation supports two ways of associating the buddy class:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Explicit: using an attribute on the model partial class that points to the type of the buddy class &lt;/LI&gt;
&lt;LI&gt;Implicit: using a name matching pattern (append "_Metadata" to the name of the model class and look for a class with that new name in the current namespace/assembly) &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Using the explicit option looks like this:&lt;/P&gt;&lt;PRE class=code&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;MetadataClass&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Product_Metadata&lt;/SPAN&gt;))]
&lt;SPAN style="COLOR: blue"&gt;partial class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Product &lt;/SPAN&gt;{
}

&lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Product_Metadata &lt;/SPAN&gt;{
    [&lt;SPAN style="COLOR: #2b91af"&gt;Range&lt;/SPAN&gt;(0, 10000)]
&lt;SPAN style="COLOR: blue"&gt;    public int &lt;/SPAN&gt;Quantity { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Comment out the MetadataClass attribute and you get the implicit option.&lt;/P&gt;
&lt;H3&gt;XML file metadata&lt;/H3&gt;
&lt;P&gt;An alternative metadata provider uses an XML file as the metadata store. Currently the file location is hard-coded to be ~/metadata.xml. A very basic metadata.xml file could look like this (a slightly bigger one is included in the sample blog project of the MVC Toolkit):&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;metadata &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://tempuri.org/metadataFile&lt;/SPAN&gt;"
    &lt;SPAN style="COLOR: red"&gt;xmlns:m&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://tempuri.org/metadataElements&lt;/SPAN&gt;"
    &lt;SPAN style="COLOR: red"&gt;xmlns:xsi&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/SPAN&gt;"
    &lt;SPAN style="COLOR: red"&gt;xsi:schemaLocation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://tempuri.org/metadataFile ../Schemas/MetadataFile.xsd&lt;BR&gt;                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;http://tempuri.org/metadataElements ../Schemas/MetadataElements.xsd&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;metadataAttributes&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;metadataAttribute &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;tagPrefix&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;m&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;assembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;MVCToolkit&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Microsoft.Web.DynamicData.Metadata&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;metadataAttributes&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;tables&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;table &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Product&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;column &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Quantity&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
          &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;m:Range &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Minimum&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;0&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Maximum&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;100000&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;column&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;table&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;tables&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;metadata&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;The metadataAttributes section defines metadata attribute mappings. These are used by the logic that creates a CLR attribute type instance from an XML element. For example, the m:Range element will be converted into the class Microsoft.Web.DynamicData.Metadata.RangeAttribute in the MVCToolkit assembly. The attributes on the element are automatically converted and set on the properties of the attribute type instance. You can add your own metadata attribute collection by defining a new metadataAttribute entry.&lt;/P&gt;
&lt;P&gt;The tables section allows you to define metadata on all of the tables and their columns that make up your model. &lt;/P&gt;
&lt;P&gt;As a final note, most of the attributes on the root metadata element are there to support IntelliSense in your XML editor. The relative URLs work in the sample Dynamic Data MVC blog project. You might have to change some of the paths if you decide to move the XSD files around or if you create a new project in a different location.&lt;/P&gt;
&lt;H3&gt;Implementation details&lt;/H3&gt;
&lt;P&gt;The underlying implementation uses the TypeDescriptor mechanism from System.ComponentModel. It is basically a pluggable layer on top of standard reflection. Have a look at the code to learn more.&lt;/P&gt;
&lt;H3&gt;Conclusion&lt;/H3&gt;
&lt;P&gt;This post discusses elements that will be incorporated in some way or another in future releases of ASP.NET Extensions. However, some of the implementation details might change. We will certainly have detailed documentation for the final release.&lt;/P&gt;
&lt;P&gt;In the meantime feel free to explore the provided code and make sure you give back any feedback you might have on how these features can be improved. You can post your comments/questions at:&lt;/P&gt;
&lt;P&gt;&lt;A title="ASP.NET 3.5 Extensions Preview discussion" href="http://forums.asp.net/1147.aspx" target=_blank mce_href="http://forums.asp.net/1147.aspx"&gt;ASP.NET 3.5 Extensions Preview discussion&lt;/A&gt; &lt;BR&gt;&lt;A title="ASP.NET Dynamic Data discussion" href="http://forums.asp.net/1145.aspx" target=_blank mce_href="http://forums.asp.net/1145.aspx"&gt;ASP.NET Dynamic Data discussion&lt;/A&gt;&lt;/P&gt;
&lt;H3&gt;Additional resources&lt;/H3&gt;
&lt;P&gt;Visit these blogs for additional tips on ASP.NET 3.5 Extensions and Dynamic Data:&lt;/P&gt;
&lt;P&gt;&lt;A title="David Ebbo's ASP.NET blog" href="http://blogs.msdn.com/davidebb/default.aspx" target=_blank&gt;David Ebbo's ASP.NET blog&lt;/A&gt; &lt;BR&gt;&lt;A title="Scott Hunter: ASP.NET and .NET Musings" href="http://blogs.msdn.com/scothu/" target=_blank&gt;Scott Hunter: ASP.NET and .NET Musings&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6726671" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/marcinon/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/marcinon/archive/tags/ASP.NET+3.5+Extensions/default.aspx">ASP.NET 3.5 Extensions</category><category domain="http://blogs.msdn.com/marcinon/archive/tags/metadata/default.aspx">metadata</category><category domain="http://blogs.msdn.com/marcinon/archive/tags/MvcToolkit/default.aspx">MvcToolkit</category></item></channel></rss>