Updating to Entity Framework v.Latest the Easy Way

Entity Framework is evolving rapidly which is why they are releasing via NuGet rather than being strapped to the .NET release cycle. (You can read more about the how’s and why’s of EF’s release cycle here: http://blogs.msdn.com/b/diego/archive/2012/01/15/why-entity-framework-vnext-will-be-ef5-and-nothing-else.aspx ).

The following is about keeping current with Entity Framework Code First and DbContext, not about upgrading the core API that is in .NET.
EF 4.1 – 4.3.1 work with .NET 4.0.
EF 5 (currently in beta) will work with .NET 4.5 (also currently in beta).

It’s recommended that you keep your apps that use EF (Code First/DbContext) up to date. The updates add functionality and fix some bugs, so this is a fairly safe prospect (granted there were a few problems for some very particular scenarios in the past but those have been corrected).

Thanks to the NuGet integration in Visual Studio it’s really easy to update EF assemblies across a solution without having to update each project that might need it. (You’ll need NuGet installed in VS which you can do via the Extension Manager.)

Right click the solution in Solution Explorer and click Manage NuGet Packages for Solution.

nugetefupdate1

Select Updates (circled in the image). The dialog will show you any packages for which updates are available. My solution has 5 projects and I am using EF 4.1 in four of them. So the tool sees that I’ve got those installed and that there’s a newer version available, so it presents that to me. Click Update.

nugefupdate2

 

Now I am presented with all of the projects that are using an out-of-date version of Entity Framework. By default, they are all checked to have the most current version installed. Click OK.

nugetefupdate3

 

As NuGet updates the packages in your projects, it will show the progress for each package. Here I can see that my console app project has just been updated from 4.1 to 4.3.1.

nugetefupdate4

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

4 thoughts on “Updating to Entity Framework v.Latest the Easy Way

  1. You can also use the package manager console for this. Just start the package manager console and enter this command:

    Update-Package EntityFramework

    You can also leave off the ‘EntityFramework’ argument to that command, which will update ALL the packages in your solution, but that might not always be what you want to do 🙂

  2. ahh yes, the console too. 🙂 Thanks. It’s funny that for NuGet stuff I can do in the visual tool, I don’t think of the console even though I use that for many other tasks.

  3. But when you use the command line, don’t you have to do it for each project separately?

    Or can you update all projects using the command line with the latest EF (and not affect any other NuGet Packages)?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.