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.

Author: John

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 99 books and over 600 articles to date. The topics range from networking to artificial intelligence and from database management to heads-down programming. Some of his current books include a Web security book, discussions of how to manage big data using data science, a Windows command -line reference, and a book that shows how to build your own custom PC. His technical editing skills have helped over more than 67 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Compute magazines. He has also contributed articles to magazines such as Software Quality Connection, DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer. Be sure to read John’s blog at http://blog.johnmuellerbooks.com/. When John isn’t working at the computer, you can find him outside in the garden, cutting wood, or generally enjoying nature. John also likes making wine and knitting. When not occupied with anything else, he makes glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at John@JohnMuellerBooks.com. John is also setting up a website at http://www.johnmuellerbooks.com/. Feel free to take a look and make suggestions on how he can improve it.