Entity Framework tutorial -- install Entity Framework environment, entityframework
Install the Entity Framework Environment
Entity Framework 5.0 APIs are distributed in two places. One can be found in the NuGet Package Manager and the other exists in the. NET framework .. NET framework 4.0/4.5 contains EF core APIs. EntityFramework. dll downloaded through the NuGet Package Manager contains the special functions of EF5.0.
However, in EF6.0, you only need to download EntityFramework. dll from the NuGet Package Manager, instead of relying on. NET framework.
This basic tutorial is written in EF6.0. Install the following tools before learning:
- NET Framework 4.5
- Visual Studio 2012
- Ms SQL Server 2005/2008/2012 Express
Install EF through NuGet
You can install EF (EntityFramework. dll) through the NuGet Package Manager and select different versions in the same way.
Right-click solution and select NuGet Package Manager.
The NuGet Package Manager dialog box is displayed. Open the Online option on the left and search for EntityFramework.
This searches for all the packages related to the Entity Framework. Select the Entity Framework and install it.
Click agree in the license authorization dialog box to start installation.
After installation, make sure that your project contains EntityFramework. dll.
Now you can use Entity Framework in your project!
Install Database
This tutorial uses a simple database SchoolDB, which contains multiple tables, stored procedures, and views. Its design is as follows:
The above databases have the following relationships for Demonstration:
- One-to-one relationship: Student table and StudentAddress table. Student has zero or one StudentAddress.
- One-to-multiple: The Standard table and Teacher table have one-to-multiple relationships. Multiple teachers are associated with a Standard.
- Many-to-many: the Student table has many-to-many relationships with the Course table, and uses the StudentId column and CourseId column of the StudentCourse table to link two tables. Therefore, one student can attend multiple courses, and multiple students can attend one course.
Download Project
This project contains the database script and EF design model.