eFORCE
Blogs Home | Corporate Website

Thursday, August 14, 2008

Dynamic Data Part1 - Your First Dynamic Data Website

Your First Dynamic Data Site
Microsoft’s .Net 3.5 SP1 of is here and it brings with it some of the most exiting enhancements in .NET 3.5. ASP.Net - Dynamic Data is one of them.  Dynamic Data is a scaffolding framework. It generates CRUD operations from your database schema. What gives an edge to Dynamic Data over some of the existing scaffolding frameworks (like monorail) is the fact that it is fully template driven and highly customizable.

Install .Net SP1

Download and install the .Net 3.5 SP1. You will find two new templates as you try to create a new website. These templates namely, DynamicDataEntityFrameworkWebSite and  DynamicDataLinqToSqlWebSite allow you to quickly create a dynamic data site.
   
   
DynamicDataLinqToSqlWebSite Template: Creates a Dynamic Data web application using a LINQ to SQL data model to generate the scaffolds.
DynamicDataEntityFrameworkWebSite Template: Creates a Dynamic Data web application using Entity Data Model (ADO.NET Entity Framework) to generate the scaffolds.
We will use the DynamicDataLinqToSqlWebSite for this example. Here we go …
 
   
1.
Let us create a Dynamic Data Website by choosing DynamicDataLinqToSqlWebSite template and call it MyDynamicDataSite. You will find that the WebSite has a folder called DynamicData, which has all the template controls and pages which will be used to generate CRUD operation on the tables.
 
 

 

 

2.

 Let us create our Data model using LinqToSql Classes. I have used “Company” database in this example. Let us call our LINQ to SQL class Company.dbml.

 
 

 

 

3.

The Final step is to enable scaffolding. This is done by un-commenting the following lines of code in the global.asax:

 
 

 

 model.RegisterContext(typeof(YourDataContext), new ContextConfiguration() {

ScaffoldAllTables = false });



 

 

 
 
 

Replace the YourDataContext with “your” DataContext that is with CompanyDataContext and turn  ScaffoldAllTables to true:

 
 

 

 model.RegisterContext(typeof(CompanyDataContext), new ContextConfiguration() {

ScaffoldAllTables = true} );

 
 

 

And that’s all you have to do. Run the site and see the magic.

You will find the Dynamic Data has generated CRUD operation on all the tables in your Data Model without you needing to write a single line of code.

It’s Amazing.

 
     

Conclusion:

This was a very simple “hello world” kind of demonstration of how ASP.NET Dynamic Data can provide with basic CRUD operations on your site in matter of minutes.

In future posts we will try to dive deeper into some of the concepts that’s been overviewed here.

Till then, happy programming!

   

posted @ Thursday, August 14, 2008 3:37 AM | Feedback (0)

Home
Contact
RSS 2.0 Feed
Login
August, 2008 (1)
April, 2008 (1)

Powered by: