Upgrading ASP.NET 5 Beta4 to Beta5


officetoolsFor my upcoming course, I have a decent sized example that I’ll be teaching from. In the process of watching ASP.NET 5 go through the sprints, I have to upgrade the project at every step. I feel at some point I should be getting better at dealing with the sprints, but not yet ; )

Here is a short post that includes the different things I had to deal with in upgrading the project. It’s not just the ASP.NET 5 update, but also EF7 and a couple of small details.

First, I followed these instructions I found as an answer to an upgrade problem on SO. It got me close:

http://stackoverflow.com/a/31281489/40125

Next I found that there were a couple of changes for EF7 to work:

First I found that the name of the optionsBuilder had changed in the DbContext.OnConfiguring method. It used to be called DbContextOptionsBuilder, but in beta 5 it’s called EntityOptionsBuilder. The real rub here is that in Beta 6 it’s going to go back to the old name so you might want to note it:

// Beta6 will revert back to DbContextOptionsBuilder
protected override void OnConfiguring(EntityOptionsBuilder optionsBuilder) 
{
  optionsBuilder.UseSqlServer(Startup.Configuration.Get("Data:tripConnection"));
  base.OnConfiguring(optionsBuilder);
}

Next, I noticed that my use of Include in LINQ queries wasn’t working. Include is now an extension method so I needed to add the namespace:

using Microsoft.Data.Entity;

Lastly, if you’re like me and your Tag Helpers are not working, make sure you didn’t miss the small change that the _GlobalImports.cshtml is now _ViewImports.cshtml. If not, the tag helpers won’t be included.

HTH!


Ready to Learn Vue with ASP.NET Core?

Shawn's 4-hour course will get you up to speed in no time. Vue.js is a great middle-ground between React and Angular for people who don't like the complexity of Angular, and the overly componentized React. Learn today at Wilder Minds Training!

Enroll Today


Shawn
Shawn Wildermuth
Author, Teacher, and Coach




My Courses

Wilder Minds Training
Vue.js by Example (Now Available)
Bootstrap 4 by Example
Intro to Font Awesome 5 (Free Course)
Pluralsight
Less: Getting Started (Coupon Available)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.1)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API
Web API Design

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.27129.04
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86