What did I do? I wasted hours and hours so that I can share this lesson with you. The bottom line is that I’m kindofa dope sometimes.
I had an EF 4.3 project that I moved onto a new machine with VS11 Beta.
I wanted to see the new enum support in action.
So, I installed the new EF 5 by opening up the Package Manager Console and typing in
install-package entityframework –pre
(The pre ensures that you get the latest pre-release version rather than the latest RTM…very clever )
I added in my enums and fixed up my classes and then since I was on a new machine, I ran enough code to initialize the database.
I had done this before on another machine and already seen this work, so I wasn’t quite as excited this time when I opened up the database to see what Code First had given me. But the properties that were based on my new enums were NOT THERE.
Fast forward to about 2 hours later, then sleep, then another hour this morning.
In all of that time one thing I had noticed but NOT realized was my biggest clue was that the version of EntityFramework.dll in my projects as 4.4. I thought that maybe the team had decided not to number it 5 until it was released. (No only someone as dumb as me would think of that excuse, I guess )
Finally this morning after my 2nd cup of coffee I figured it out.
Installing EF5 (beta) installs TWO packages. One that can be used with .NET 4 and one that can be used with .NET 4.5. Note that it is .NET 4.5 that brings the goods for the enum support.
So then the question was, “why did I get the .NET 4 version of EF5?” and I know the answer.
I installed the package BEFORE I updated my projects from targeting .NET 4 to targeting .NET 4.5.
So, to update an EF 4.x project to EF5 + .NET 4.5 goodies the steps are:
- Update the projects to target .NET 4.5 *first*
- Install the EF5 package into each of the relevant projects.
Hoping this saves someone the grief and waste of time that it cost me. You know…it’s just how I roll!
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
I stumbled in it right now. You really saved me a great time. Thank you!
@Kim, glad I posted it. Hey I’m curious how you found the post. Was it a web search and if so, what key words did you use?
Thanks for this info, I was preparing to upgrade soon, this will save me a lot of hassle 🙂
And I found it as I have your feed bookmarked 🙂
Thanks for using your body to shield us from the arrows of new technology, so that we learn from your mistakes and not suffer the same fate.
I tried to follow your post, but the problem when i targeted the project to 4.5, the EF5 beta-2 doesn’t contain the namespace System.ComponentModel.DataAnnotations.Schema.
and i want to use the attributes like ForeignKey and Table and DatabaseGenerated in my classes, it gives errors
Any Idea how to fix this?
@hadi, you should find all of the annotations in .NET 4.5 now. I’ll do a blog post with some screenshots. 🙂