Installing the Entity Framework Environment
The Entity Framework 5.0 API is distributed in two locations, one can be found in the NuGet Package Manager, and one exists in the. NET Framework. NET Framework 4.0/4.5 contains the EF core API. The EntityFramework.dll downloaded through the NuGet Package Manager contains special features for EF5.0.
However, in EF6.0, you only need to download EntityFramework.dll from the NuGet Package Manager and not rely on the. NET framework.
This basic tutorial is written using the EF6.0 version. Please install the following tools before learning:
- NET Framework 4.5
- Visual Studio 2012
- MS SQL Server 2005/2008/2012 Express
Installing EF through NuGet
You can install EF (EntityFramework.dll) through the NuGet Package Manager, and you can choose different versions in the same way.
Right-click on the solution and select NuGet Package Manager.
The NuGet Package Manager dialog box pops up and opens the online option on the left and looks for entityframework.
This will find all the packages related to the Entity Framework. Select the Entity Framework and click Install.
Click the Consent button in the License Authorization dialog box to start the installation.
After the installation is complete, make sure your project contains EntityFramework.dll.
Now you can use the Entity Framework in your project!
Installing the Database
The tutorial uses a simple database schooldb, which contains multiple tables, stored procedures, and views, designed as follows:
The above database has the following relationship to demonstrate:
- One-to-one: student tables and studentaddress tables are one-to-one relationships. Student have 0 or one studentaddress.
- One-to-many: the standard table and the teacher table are one-to-many relationships. Multiple teacher are associated to a standard.
- Many-to-many: the student table and the course table have many-to-many relationships, and two tables are linked through the StudentID and CourseID columns of the Studentcourse table. So a student can take more than one course, and a class with multiple students.
Download the project
The project contains database scripts and EF design models.
Entity Framework Tutorial-Installing the Entity Framework Environment