Working with NuGet to Obtain the Entity Framework

My newest book project, Entity Framework Development Step-by-Step, discusses Entity Framework 5, the latest version of the Entity Framework that Microsoft has released. However, most of the discussions you read about online discuss obtaining Entity Framework 5 using NuGet, a new method that Microsoft is using to help you download and install products for Visual Studio. The only problem is that the process for making all this work isn’t very clear for Visual Studio 2010 developers (NuGet comes installed for Visual Studio 2012 developers).

I want everyone to be able to work with my book at some point, so I’m providing you with some instructions for getting Entity Framework 5 using NuGet. Along with Entity Framework 5, you’ll also be able to obtain a number of other interesting packages using NuGet, so this isn’t a product you’ll use once and then forget about. With this in mind, let’s get started installing the Entity Framework 5 and then you can use a similar process to install other NuGet packages. (These instructions may change with time, so please contact me at John@JohnMuellerBooks.com if you experience any difficulties.)

  1. Open your copy of Visual Studio 2010.
  2. Choose Tools | Extension Manager. You’ll see the Extension Manager window open.
    NuGet01
  3. Verify that you haven’t already installed the NuGet Package Manager extension by selecting the All folder and reviewing its contents.
  4. Click the Online Gallery tab. You’ll see a Retrieving Information message for a few seconds as Visual Studio retrieves the required information. After Visual Studio finds all of the possible extensions, you see NuGet Package Manager displayed as shown here.
    NuGet02
  5. Click Download. You see a Download and Install dialog box that shows a progress indicator. After a few moments, you’ll see a UAC dialog box asking permission to run the VSIXInstaller. Click Yes and you’ll see the Visual Studio Extension Installer dialog box.
  6. Read the licensing terms and click Install. After a moment, the installation completes and you see a success dialog box.
  7. Click Close. Visual Studio will display the Extension Manager window again. Notice the Restart Now button at the bottom of the window.
  8. Click Restart Now. Visual Studio restarts and the NuGet Package Manager is ready for use.
  9. Create the new project where you want to use the Entity Framework 5.0. NuGet will absolutely refuse to install the Entity Framework unless you have a solution open. This is because installing the Entity Framework creates a new file named packages.config that contains the information about the package.
  10. Choose Tools | Library Package Manager | Package Manager Console. You see a new Package Manager Console window open.
    NuGet03
  11. At the PM> prompt, type Install-Package EntityFramework and press Enter. You see the NuGet Package Manager install Entity Framework 5.0 support for the solution you just created.
    NuGet04

 

The Package Manager Console lets you interact with NuGet and the Entity Framework. To object help with NuGet, type get-help NuGet and press Enter. Likewise, to obtain help with the Entity Framework, type get-help EntityFramework and press Enter. I’ll be providing some additional posts like this one as time permits. In the meantime, please let me know your thoughts and concerns about the Entity Framework at John@JohnMuellerBooks.com.