Migration from ASP.NET 5 Beta 7 to Beta 8

ASP.NET 5 beta 8 was released on October 15th. Read the main announcement here and the entity framework 7 specific announcement here.

The tooling update can be found here. The relevant files are either DotNetVersionManager-x64.msi or DotNetVersionManager-x86.msi depending on what your system supports and WebToolsExtensionsVS14.msi.

The above gets everything needed for use inside Visual Studio for more details on other options check out Microsoft’s documentation for getting started with Windows, Mac or Linux.

After completing the upgrade open global.json and update the sdk version to beta 8.

Next up is project.json which has more changes than other migrations due to the move from hosting in Helios to Kestrel. First update beta7 to beta8 in the dependencies section.

Note that Microsoft.AspNet.Server.IIS and Microsoft.AspNet.Server.WebListener have been removed. Microsoft.AspNet.IISPlatformHandler and Microsoft.AspNet.Server.Kestrel have been added.

In the commands section the web command has been updated to use Kestrel.

As a result of the move to Kestrel both hosting.ini and wwwroot\bin\AspNetLoader.dll can be deleted. In wwwroot the web.config file changed to the following.

Startup.cs had a few changes. First in the constructor the application’s base path moved out of the constructor of ConfigurationBuilder to the SetBasePath function.

In ConfigureServices the setup for third-party authentication has been removed. For example the following has been removed.

Third party authentication options are now set in the Configure function. Here is an example with Facebook.

Also in the Configure function app.UseErrorPage is now app.UseDeveloperExceptionPage and app.UserErrorHandler is now app.UseExceptionHandler.

Add the platform handler to the request pipeline before app.UseStaticFiles.

In AccountController.GetCurrentUserAsync and ManageController.GetCurrentUserAsync Context is now HttpContext.

Next up are the changes related to entity framework 7. EF7 had a lot of API changes with this release. I am covering the ones related to the app I am working with and others can be found by looking at the commits related to this issue.

The designer.cs that goes with migrations drop the override of Id in favor of a migration attribute instead. The new attribute can be found in Microsoft.Data.Entity.Migrations.

Migration related renames
Old New
Key HasKey
Reference HasOne
InverseCollection WithMany
ConcurrencyToken IsConcurrencyToken
isNullable nullable

After all the above changes my project built, but would error because entity framework was trying to run migrations that had already been applied. After some digging I found that the table used to check if a migration has been applied or not had been renamed from MigrationHistory to EFMigrationsHistory. The following SQL will move the migrations that have been applied from the old table to the new one.

After fixing the migration issue the app ran with no problems. Make sure and check out the release page and the breaking changes page for this release.

Also note that the ASP.NET 5 project templates for Visual Studio have been open sourced and can be found here. The templates are a great resource which I used to work through a couple of issues when doing the migration to beta 8.

17 thoughts on “Migration from ASP.NET 5 Beta 7 to Beta 8”

      1. Entity Framework always gives me a lot of issues when moving to new versions. I find it easier to just delete the migrations and generate them from scratch.

        The name of the Migrations table which has changed was a good catch though – that would have kept me busy for a while if you did not highlight it 🙂

        1. Regeneration is definitely the easiest way to go.

          After this blog post I ended up redoing the whole project from scratch with the new version. This is a big set to changes so it seemed like a good time.

  1. Any known differences or quick thoughts why the Microsoft.Xrm.Client dll used to connect to CRM cannot seem to find its configuration element in web.config anymore? This was working in beta6, but with the move to beta8 and Kestrel, I receive the following error, “A configuration element with the name ‘Xrm’ under the ‘contexts’ collection does not exist.”

    I am pretty sure I have the correct setup in web.config –

  2. Following up on my own question – I did get this working and I believe this is what did it was:
    1) Added an ‘app.config’ at the root of the ASP.NET project. (Note, it was not necessary to call ConfigurationBuilder.AddXmlFile(“app.config”) during Startup().
    2) Added a reference to the “Microsoft.Framework.Configuration.Abstractions” NuGet package to the repository project that called into CRM. I’m not sure this is required, but it now works and I’m not messing with it further.

Leave a Reply

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