Part 2: Data Access Layer

by Joe Stagner

Tailspin Spyworks demonstrates how extraordinarily simple it is to create powerful, scalable applications for the .NET platform. It shows off how to use the great new features in ASP.NET 4 to build an online store, including shopping, checkout, and administration.

This tutorial series details all of the steps taken to build the Tailspin Spyworks sample application. Part 2 covers adding the data access layer.

Adding the Data Access Layer

Our ecommerce application will depend on two databases.

For customer information we'll use the standard ASP.NET Membership database. For our shopping cart and product catalog we'll implement a SQL Express database as follows.

Screenshot that shows the S Q L Express database structure.

Having created the database (Commerce.mdf) in the application's App_Data folder we can proceed to create our Data Access Layer using the .NET Entity Framework.

We'll create a folder named "Data_Access" and them right click on that folder and select "Add New Item".

In the "Installed Templates" item and then select "ADO.NET Entity Data Model" enter EDM_Commerce.edmx as the name and click the "Add" button.

Screenshot that shows where to select A D O dot NET Entity Data Model.

Choose "Generate from Database".

Screenshot that shows where to select Generate from database.

Screenshot that shows the entity connection string.

Screenshot that shows where to select the database objects.

Screenshot that shows the built database structure.

Save and build.

Now we are ready to add our first feature – a product category menu.