Setup Development Environment for EF Code-First:

Let's setup the development environment for Code-First before starting on it.

Install the following tools to work with Entity Framework Code-First:

  • .NET Framework 4.5
  • Visual Studio 2012
  • MS SQL Server 2008/2012 Express

Install EF via Nuget:

Here, we will install Entity Framework API (EntityFramework.dll) via NuGet in the VS 2012 console application. (You can install EF via NuGet the same way in any version of Visual Studio.)

First, create the console application. Right click on your project in the solution explorer and select Manage NuGet Packages..

code-first environment setup

This will open Manage NuGet Packages dialogue box. Now, select Online in the left bar and search for EntityFramework as shown below.

Entity Framework install

This will search for all the packages related to Entity Framework. Select EntityFramework and click on Install.

Entity Framework install

Click on the I Accept button in the License Acceptance dialogue box to start the installation.

Entity Framework install

After installation, make sure that the appropriate version of EntityFramework.dll is included in the project.

Entity Framework install

Now, we are ready to use Entity Framework Code-First in our sample console project. Let's start writing our first simple code-first example in the next section.