A Visual Studio project which shows how to use the Entity Framework in an ASP.NET Web Forms web application project, using the Database First workflow and the EntityDataSource control. The code illustrates the following topics:
- Performing basic CRUD operations.
- Filtering, ordering, and grouping data.
- Working with related data.
- Table-per-hierarchy inheritance.
- Using stored procedures.
- Using Dynamic Data functionality.
For handling concurrency using the EntityDataSource, see
version 2 of this project. For tutorials that show you how to create the project, see
Getting Started with the Entity Framework.
To build and run this sample, you must have Visual Studio 2010 installed. Unzip the CSContosoUniversity.zip or VBContosoUniversity.zip file into your Visual Studio Projects directory (My Documents\Visual Studio 2010\Projects) and open the ContosoUniversity.sln
Running the Sample
To run the sample, hit F5 or choose the Debug | Start Debugging menu command. You will see the home page which includes a menu bar.
From this page you can select any of the tabs to perform various actions such as display a list of students, add new students, display a list of courses, and so forth.
Source Code Overview
The ContosoUniversity folder includes the following folders and files
- Account folder - Unchanged from what the project template creates. Note that this project does not implement membership functionality.
- App_Data folder - Holds the SQL Server Express database file.
- DAL folder - The data access layer. Holds the .edmx file and a partial class with data annotations for the Student entity.
- Properties or MyProject folder - Unchanged from what the project template creates.
- Scripts folder - Unchanged from what the project template creates.
- Styles folder - Holds the CSS file, which contains minor changes from what the project template creates.
- Web page files
- Global.asax file - Unchanged from what the project template creates.
- Site.master - Master page file. Specifies the layout of all site pages.
- Web.config file - Contains the connection string to the database.