This is a story all about how, my life got flipped….OK, I’ll stop there. BUT, when I was younger and first getting into development I started off broke as anything and couldn’t afford Visual Studio…. I always love telling this story. I asked some of my coworkers “What should I learn?” (previously I had developed in BASIC so I wasn’t a 100% n00b).
PHP has been a fallback if I ever want to do quick and dirty development. Since you can setup a LAMP stack with almost $0 cost anytime I was down on my luck and wanted to work on something I could always depend on it. It’s been pretty same, and besides the switch from mysql to mysqli (which there are multiple equivalents 1:1) PHP has been old trusty. However with my latest positions it’s been C# or VB.net and that’s lead to a few ‘hiccups’ per se (I failed an interview because I had an array question that I handled as a list, and when the interviewer wasn’t aware of the new methods with list he thought I was lying).
But Shawn, your title…yeah I know.
So, at work I use Visual Studio 2013, and had it on my laptop when I first started learning MVC with EF, and all was right with the world. Doing Code First Migrations I updated my class, added a Migration, update the database and kept moving. I went to lunch with some friends (Hi Tim and Erik), and bragged about how easy EF was with Code First, and how I was under the impression that MVC was going to rule the world with an iron fist.
Then life happened.
A wedding, a birth, a death, an adoption, a reunion, a Christmas party, my daughter getting into a competition, birthday trips, and the list goes on. Mind you not everything is applicable to me, however being supportive of others, things happen and that takes you away from things. So, ASP.NET with EF & Code First Migrations was put on the back burner as a side project/learning experience.
Horray!!! Visual Studio 2015 and Windows 10 is released! I promptly download them and putz around with C# in 2015…life starts getting better again.
So, here it is, Jan 2016 and I’m ready to get back into ASP.NET MVC & EF. Let’s fire up a site, but I know I’m going to want to go with EF…I know what I’m doing, so ‘Install-Package EntityFramework’….and I get “EntityFramework is already installed”. Weird, this is a new project, why is EF already part of it? Oh well, maybe I did it out of habit…let’s move on. Modify a class, OK that’s good let’s work with what we know…”Add-Migration <MigrationName>”…Oh dear god above what’s happened? EVERYTHING DIES.
Now when I say everything dies, what I mean is the Package Manager throws a cmdlet error saying that Add-Migration isn’t recognized which I know is bullshit because that’s the routine, Install EF, Add Migration, Update Database, I KNOW WHAT I’M DOING!!! Don’t tell me I’m wrong! But, my project is probably corrupt, so I start a new project make sure that I selected ASP.NET MVC, give my project a name, open Package Manager Console, Install-Package EntityFramework, hit enter, and ‘EntityFramework is already installed’.
It’s happening again….BUT WHY?!
Looking on Stack Overflow, I see where other people are talking about EF throwing errors and how it’s related to needing to run dnx and dnu commands…None of this applies to me, I’m already at some level of corruption from the initial project creation. But what?!
I spend the next few hours looking up changes on what happened between ASP.NET MVC 4 and 5, who cares, the problem isn’t ASP.NET, the problem is EF and what it’s doing to my project right out of the gates. It’s slowly approaching 3am and I need to go to bed to be up for work by 6. Then I find an article on MSDN: Getting Started with Entity Framework 6 Code First using MVC 5. *sigh* this doesn’t apply, I’m using ASP.NET 4.5 and whatever bundled version of EF that comes with…moving on. I find more articles… Entity Framework Code First to a New Database, I’ve done all this, why? Oh why?! What did I do to make Visual Studio upset?! I have Visual Studio, I’ve used MVC (I use it at work), I’ve messed with EntityFramework before successfully, where did I go wrong? In desperation, I download Visual Studio 2013 to attempt to figure out what I’m doing wrong or was all my previous successes all a dream?
Was it all a dream?
Opening up Visual Studio 2013 and trying again, ‘EntityFramework is already installed’. Ha! I’m not crazy, something changed! Someone somewhere is messing with me, BUT I can build the project, so MVC didn’t *change* something with the underlying platform changed. Did EF change?
OK, I’m going back to the begining. Something changed and I don’t know where. I start searching for “What’s new in Visual Studio 2015” Where I find Scott Guthrie’s Blog post:
Released Today: Visual Studio 2015, ASP.NET 4.6, ASP.NET 5 & EF 7 Previews
OK, fair enough, looking through, I find the headlines ASP.NET 5 and Entity Framework 6 along with the RTM release notes. With the following sentence “EF 6.1.3 primarily focuses on bug fixes and community contributions”….yada, yada, yada….”Additionally, the runtime is pre-installed in new ASP.NET projects, depending on the project template you select.”. Reading the release notes, I see…
- The tooling will be included in future releases of Visual Studio 2015 (currently in preview).
OK, I’m not in Kansas anymore (though, I do miss the rains down in Africa). I apparently AM now a n00b and need to follow up appropriately. Going back to the beginning and Hello World.
I keep reading, going through the tutorial until I see this screen.
I don’t have those ASP.NET 5 Templates though, but I do have Entity Framework 6.1.3. Where it says ASP.NET 5 Templates, I see a “Get ASP.NET 5 RC”, this begins downloading the ASP.NET 5 Framework, which includes the tooling for Entity Framework 6.1.3. That’s right this was all separate. It’s no longer Install-Package EntityFramework, it’s well, you should find out here.
I guess the lesson of the story here is when you make a jump in your tools, in your frameworks, in your technologies, it’s always better to RTFM vs. assuming everything just stayed the same.