When Written: April 2009
Going back to our imaginary web site, one job that often needs to be done with a database driven web site is the building of some administration pages for inputting of data via a web page . This can be a tedious job but it is obviously very important to get it right and to make sure all the relationships between the various tables are maintained, so if a record is edited or deleted the links to the other tables do not become broken. There are several ‘code writing’ add-ins around but the solution that Microsoft has come up with in Visual Studio2008 is particularly neat. It is called the Dynamic Data Entity web site.
The approach here is rather different as the pages that are generated are not customised based on the design of database tables but rather they are ‘intelligent’ pages that know about the database structure. Each of these pages can be further customised very easily to add more functionality if you wish, such as adding a calendar control for inputting a date field. The steps to creating these administration pages are quite simple. First create a new web site in Visual Studio 2008 of type Dynamic Data Entity next you add a data connection to link to your database. This database needs the relationship between its tables already defined within its database diagram. Next add a new item to your project of ADO .NET Entity Data Model and follow the wizard.
After a few moments a diagram will appear showing the various tables in your database as well as their relationships. You can customise these links here as well as connect to other data sources if necessary. Once done you need to uncomment a couple of lines in the global.aspx file to point to the data model and data connection. Now run it and all being well you should have a set of admin pages that you could leave right there or simply alter their look by changing the master page.

This is a great way to generate admin pages for a database using Dynamic Data Entity web site in VS2008
If you want to customise the pages further then they are fully editable as ASP .NET pages. This a really neat way of producing these type of pages in a slick and dynamic way if you later need to add a field to a table or even another table the pages will reflect these changes without any alteration as long as the model page is refreshed from the database.
Well done Microsoft!
Article by: Mark Newton
Published in: Mark Newton