Tuesday, August 7, 2012

Make a Dynamically Data Driven Website in less than 5 minutes–ASP.Net Dynamic Data Entities Web Application

Want a fully functioning dynamic data website in less than 5 minutes?  ASP.Net Dynamic Data Entities Web Application is the way to go.  Nothing could be simpler.  Create the project | Add a datasource | deploy the site… It’s that easy. 

Let’s start off by creating the Project.   In VS2010, Click File | New Project.  You will be presented with a modal window like below -
image

 

In the template pane, select Visual Studio | Web.  In the Project pane select ASP.Net Dynamic Data Entities Web Application.  Name your site appropriately (I named mine FirstDynamicSite) and store it in an applicable location | Click OK. 
Microsoft will create a templated site for you and land you on the Global.asax.vb page.  If you look in your Solution Explorer, it should look similar to this -
image

 

Out first order of business is to create a data connection.  So go to your Server Explorer | Right Click Data Connections | Add Connection.  You will be presented with a model window like the following -
image

Insert a correct Server Name, Credentials and Database to connect to and click OK.

Now we need to create the model.  In the Solution Explorer, RIght Click your solution name and click Add | New Item.  You should be presented with  a modal window like so -
image

 

In the template pane, Click Visual Basic | Data.  In the Items pane click ADO.NET Entity Data Model.  Give it an appropriate name (I named mine NorthwindModel.edmx) | Click Add.  Choose Generate from Database (Click Next).  Note the Entities name in the following section -
image

Click Next.
In the next section it will ask you what objects you wish to have as a part of the Model.  Here I randomly selected several tables that have relationships (For instance, Employees, Customers, Orders, & OrderDetails).  Once you select your tables, Click Finish.

It will give you a GUI representation of the tables you selected.  Lets go back to the Global.asax.vb.  Un-comment the following code -

DefaultModel.RegisterContext(GetType(YourDataContextType), New _
ContextConfiguration() With {.ScaffoldAllTables = False})




Change the “YourDataContextType” to the name of the entities that you were supposed to note from the above pricture.  Also, make ScaffoldAllTables = True, Like so -



DefaultModel.RegisterContext(GetType(NorthwindEntities), New _
ContextConfiguration() With {.ScaffoldAllTables = True})




Press F5 (To Debug) and you should see your completely functional Dynamic Data Driven Website -

image



 



Click on a table name and you can see the details and such of the table.  You can further Edit | Delete | and Add additional information to the tables.



When you need to rapidly deploy a Dynamic Data Site, you can do so in under 5 minutes by using this method and the tools Microsoft has templated for you.



Happy .Netting…

2 comments:

  1. Personally I like your blog because it has some good information regarding ASP.NET Development Services. I enjoyed this post too because I am waiting your new article all the time.

    ReplyDelete
  2. Hello Guys very nice blog for .net

    .Net Development is a technology developed by Microsoft Corporation. It is meant for the development of dynamic website and web application. Due to its compress code structure, development time gets reduced drastically......

    thanks.

    ReplyDelete