<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/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>Gil Fink&amp;#39;s Blog : ADO.NET, Dynamic Data</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/tags/ADO.NET/Dynamic+Data/default.aspx</link><description>Tags: ADO.NET, Dynamic Data</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Adding Metadata to Entities in The Data Model</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx</link><pubDate>Thu, 20 Jan 2011 19:28:37 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:775344</guid><dc:creator>Gil Fink</dc:creator><slash:comments>0</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/gilf/commentapi.aspx?PostID=775344</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx#comments</comments><description>&lt;h1&gt;Adding Metadata to Entities in The Data Model&lt;/h1&gt;  &lt;p&gt;Sometimes I’m being asked how to add metadata to a generated entity in Entity Framework. &lt;a href="http://blogs.microsoft.co.il/blogs/gilf/.Net-Framework-New-Logo_6799D4C9.gif"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;float:right;border-top:0px;border-right:0px;padding-top:0px;" title="Adding Metadata to Entities in The Data Model" border="0" alt="Adding Metadata to Entities in The Data Model" align="right" src="http://blogs.microsoft.co.il/blogs/gilf/.Net-Framework-New-Logo_thumb_261F2270.gif" width="240" height="74" /&gt;&lt;/a&gt;This metadata can be data annotation or other attributes which can help the developer during runtime. One answer that I give is to edit the T4 template in order to add the attributes. This solution can be combined with the building of an extension to Entity Framework designer which can add more details to the EDM. But it can take some time to develop. Another solution is to create a MetadataType for the entity and use the entity’s partial class behavior to add this type. This post will show you the second solution.&lt;/p&gt;  &lt;h3&gt;Adding Metadata to a Generated Entity&lt;/h3&gt;  &lt;p&gt;In the example I’m going to use the following simple entity:   &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/Entity-Designer-Diagram_52C7DC49.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Entity Designer Diagram" border="0" alt="Entity Designer Diagram" src="http://blogs.microsoft.co.il/blogs/gilf/Entity-Designer-Diagram_thumb_037AE3F5.png" width="185" height="176" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This type is part of a Dynamic Data site and the requirements for it are not to show the TypeID and that the Url needs to be up to 100 characters. Since Dynamic Data work with Data Annotations I want to add this metadata to the entity. But the problem is that the entity is generated by Entity Framework code generation. So how can I add the annotations? using the MetadataType attribute. The MetadataType is an attribute that is part of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx"&gt;System.ComponentModel.DataAnnotations&lt;/a&gt; assembly. It indicates that the a data model class has an associated metadata class. The MetadataType attribute gets a type parameter to specify which type is holding the metadata for the class. We can use the fact that the entity is generated as partial class and add the MetadataType attribute to it. Lets look at an example of how to use the MetadataType attribute:    &lt;br /&gt;    &lt;div style="border-bottom:gray 1px solid;border-left:gray 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;padding-top:4px;"&gt;     &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;       &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; CRMTypeMetadata&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    [ScaffoldColumn(&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)]&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; TypeID { get; set; }&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    [StringLength(100)]&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Url { get; set; }&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;[MetadataType(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(CRMTypeMetadata))]&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; CRMType&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;

      &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;The first thing to notice in the example is that I’ve created a public class by the name CRMTypeMetadata which hold the properties annotated with the relevant attributes. The Metadata postfix in the class name is a convention that I encourage you to use. After I create the metadata class all I need to do is to create a partial class for the generated entity and annotate it with the MetadataType attribute. The MetadataType attribute will get as a parameter the type of the metadata type which is CRMTypeMetadata in the example. That is all. 
  &lt;br /&gt;Now the expected behavior was achieved.&lt;/p&gt;

&lt;h3&gt;Summary&lt;/h3&gt;

&lt;p&gt;One of the solutions to add metadata to entities in the Entity Data Model is by using the MetadataType attribute. It is very simple to use and can help you in frameworks like ASP.NET MVC, Dynamic Data, WCF Ria Services and more. &lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px;padding:0px 0px 0px 0px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx&amp;amp;bgcolor=6600FF" /&gt;&lt;/a&gt; &lt;a href="http://dotnetshoutout.com/Submit?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx"&gt;&lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2011/01/20/adding-metadata-to-entities-in-the-data-model.aspx" style="border:0px;" /&gt;&lt;/a&gt; &lt;a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;amp;username=gilf"&gt;&lt;img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0;" /&gt;&lt;/a&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=3672056" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=775344" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Data+Access/default.aspx">Data Access</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/ADO.NET/default.aspx">ADO.NET</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Dynamic+Data/default.aspx">Dynamic Data</category></item><item><title>Create Your First Dynamic Data Entities Web Application</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/2009/10/07/create-your-first-dynamic-data-entities-web-application.aspx</link><pubDate>Wed, 07 Oct 2009 11:45:12 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:420538</guid><dc:creator>Gil Fink</dc:creator><slash:comments>5</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/gilf/commentapi.aspx?PostID=420538</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/gilf/archive/2009/10/07/create-your-first-dynamic-data-entities-web-application.aspx#comments</comments><description>&lt;h1&gt;&lt;strong&gt;Create Your First Dynamic Data Entities Web Application&lt;/strong&gt;&lt;/h1&gt;  &lt;p&gt;Two weeks ago I was &lt;a href="http://blogs.microsoft.co.il/blogs/gilf/VS2008Logo_3E9E4D04.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;margin-left:0px;border-top:0px;margin-right:0px;border-right:0px;" title="Create Your First Dynamic Data Entities Web Application" border="0" alt="Create Your First Dynamic Data Entities Web Application" align="right" src="http://blogs.microsoft.co.il/blogs/gilf/VS2008Logo_thumb_63C34983.jpg" width="284" height="61" /&gt;&lt;/a&gt;     &lt;br /&gt;asked if there is a way     &lt;br /&gt;to build a &lt;strong&gt;web back office&lt;/strong&gt;    &lt;br /&gt;quickly. One thing that     &lt;br /&gt;popped into my mind was    &lt;br /&gt;the new &lt;strong&gt;ASP.NET Dynamic Data&lt;/strong&gt;    &lt;br /&gt;framework that was shipped with     &lt;br /&gt;&lt;strong&gt;Visual Studio 2008 SP1&lt;/strong&gt;. This post is the same introduction that I     &lt;br /&gt;made to the team members that asked me the question. Since     &lt;br /&gt;there weren’t any customizations needed in the &lt;strong&gt;back office&lt;/strong&gt; they     &lt;br /&gt;needed the result was a standing &lt;strong&gt;back office&lt;/strong&gt; in 5 minutes. That is     &lt;br /&gt;very productive.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Creating the Dynamic Data Application&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;The first thing to do is to create the &lt;strong&gt;Dynamic Data&lt;/strong&gt; application.     &lt;br /&gt;This is a very easy job since we can pick one of &lt;strong&gt;Dynamic Data&lt;/strong&gt; templates     &lt;br /&gt;which will generate the site. In &lt;strong&gt;Visual Studio&lt;/strong&gt; choose &lt;strong&gt;File&lt;/strong&gt; menu&amp;#160; &lt;br /&gt;and &lt;strong&gt;New –&amp;gt; Project&lt;/strong&gt; or &lt;strong&gt;New –&amp;gt; Web Site&lt;/strong&gt; and then choose one of    &lt;br /&gt;&lt;strong&gt; Dynamic Data&lt;/strong&gt; templates on the Web templates. The options are     &lt;br /&gt;&lt;strong&gt;Dynamic Data Web Application&lt;/strong&gt; which will generate a general &lt;strong&gt;Dynamic      &lt;br /&gt;Data&lt;/strong&gt; application or &lt;strong&gt;Dynamic Data Entities Web Application&lt;/strong&gt; which is     &lt;br /&gt;more appropriate to use with &lt;strong&gt;Entity Framework&lt;/strong&gt; or &lt;strong&gt;LINQ to SQL&lt;/strong&gt;.     &lt;br /&gt;I chose the second:    &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/DynamicDataEntitiesNewProject_410211C6.jpg" target="_blank"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Dynamic Data Entities New Project" border="0" alt="Dynamic Data Entities New Project" src="http://blogs.microsoft.co.il/blogs/gilf/DynamicDataEntitiesNewProject_thumb_7223DD17.jpg" width="420" height="317" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After pushing the &lt;strong&gt;OK&lt;/strong&gt; button &lt;strong&gt;Visual Studio&lt;/strong&gt; generates the&lt;strong&gt; Dynamic Data&lt;/strong&gt;    &lt;br /&gt;application and we are clear to go. The result will look like:    &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/DynamicDataEntitiesSolutionExplorer_6C6DE4D3.jpg" target="_blank"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Dynamic Data Entities Solution Explorer" border="0" alt="Dynamic Data Entities Solution Explorer" src="http://blogs.microsoft.co.il/blogs/gilf/DynamicDataEntitiesSolutionExplorer_thumb_68EF53E9.jpg" width="420" height="586" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Adding ADO.NET Entity Framework to the Application&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;When we have the application at hand now we need to create the &lt;strong&gt;Entity      &lt;br /&gt;Framework&lt;/strong&gt; model. This is very straight forward. You can choose to create a     &lt;br /&gt;different class library and put the model there (the preferred way) or you     &lt;br /&gt;can just put the model in the created project. For the simplicity of this demo    &lt;br /&gt;I chose the second option and the result is the model I’m using in all my demos:    &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/EntityDesignerDiagram_3621DE26.jpg" target="_blank"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Entity Designer Diagram" border="0" alt="Entity Designer Diagram" src="http://blogs.microsoft.co.il/blogs/gilf/EntityDesignerDiagram_thumb_2779C2F2.jpg" width="420" height="247" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Since this is only a demo for &lt;strong&gt;Dynamic Data&lt;/strong&gt; and not for &lt;strong&gt;Entity Framework&lt;/strong&gt;     &lt;br /&gt;I’m not showing how to create the model. If you seek information about how     &lt;br /&gt;to create an &lt;strong&gt;Entity Framework EDM&lt;/strong&gt; I encourage you to read my     &lt;br /&gt;&lt;a title="ADO.NET Entity Framework Tutorials" href="http://blogs.microsoft.co.il/blogs/gilf/pages/ado-net-entity-framework-tutorials.aspx" target="_blank"&gt;&lt;strong&gt;ADO.NET Entity Framework Tutorials&lt;/strong&gt;&lt;/a&gt; series and in particularly the post    &lt;br /&gt;&lt;a title="Entity Data Model (EDM) In Entity Framework" href="http://blogs.microsoft.co.il/blogs/gilf/archive/2008/04/18/entity-data-model-edm-entity-framework.aspx" target="_blank"&gt;&lt;strong&gt;Entity Data Model (EDM) In Entity Framework&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Integrating the Context to the Dynamic Data Application&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;Now that we have the application and the &lt;strong&gt;Entity Framework&lt;/strong&gt; model     &lt;br /&gt;it is time to combine them both. We do so by opening the &lt;strong&gt;Global.asax&lt;/strong&gt;    &lt;br /&gt;file and in the &lt;strong&gt;RegisterRoutes&lt;/strong&gt; we register the context using the model     &lt;br /&gt;object’s &lt;strong&gt;RegisterContext&lt;/strong&gt; method. Pay attention that I set the    &lt;br /&gt; &lt;strong&gt;ScaffoldAllTables&lt;/strong&gt; to true in order to show all the entities in my context.    &lt;br /&gt;If you want to show only part of them set the &lt;strong&gt;ScaffoldAllTables&lt;/strong&gt; to false     &lt;br /&gt;and for every entity you want to show create a partial class and add there    &lt;br /&gt;the &lt;strong&gt;[Scaffold(true)]&lt;/strong&gt; attribute.    &lt;br /&gt;After I register the context the &lt;strong&gt;RegisterRoutes&lt;/strong&gt; will look like:&lt;/p&gt;  &lt;div style="border-bottom:gray 1px solid;border-left:gray 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;padding-top:4px;"&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; RegisterRoutes(RouteCollection routes)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    MetaModel model = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; MetaModel();&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    model.RegisterContext(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(SchoolEntities), &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ContextConfiguration() { ScaffoldAllTables = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt; });&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    routes.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DynamicDataRoute(&lt;span style="color:#006080;"&gt;&amp;quot;{table}/{action}.aspx&amp;quot;&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        Constraints = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; RouteValueDictionary(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; { action = &lt;span style="color:#006080;"&gt;&amp;quot;List|Details|Edit|Insert&amp;quot;&lt;/span&gt; }),&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        Model = model&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    });&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;That is all. Now we can run the &lt;strong&gt;Dynamic Data&lt;/strong&gt; application and use it as

  &lt;br /&gt;a web back office for our application.

  &lt;br /&gt;My application looks like:

  &lt;br /&gt;&lt;strong&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/RunningDynamicDataApplication_00420A6E.jpg" target="_blank"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Running Dynamic Data Application" border="0" alt="Running Dynamic Data Application" src="http://blogs.microsoft.co.il/blogs/gilf/RunningDynamicDataApplication_thumb_590A51E9.jpg" width="420" height="242" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;Lets sum up, I showed in this post how in 5 minutes of work you 
  &lt;br /&gt;can create a working &lt;strong&gt;web back office&lt;/strong&gt; application. The &lt;strong&gt;Dynamic 
    &lt;br /&gt;Data&lt;/strong&gt; framework can be very useful in lots of scenarios such as creating 

  &lt;br /&gt;web back office for example.I suggest to give it a try and to find out 

  &lt;br /&gt;were it can fit your requirements.&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="text-align:left;margin:0px;padding:4px 4px 4px 4px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2009/10/07/create-your-first-dynamic-data-entities-web-application.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2009/10/07/create-your-first-dynamic-data-entities-web-application.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" alt="DotNetKicks Image" border="0/" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=420538" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/ADO.NET/default.aspx">ADO.NET</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Dynamic+Data/default.aspx">Dynamic Data</category></item></channel></rss>