In the past weeks we have upgraded our ASP.NET Core 2.0 project to 2.1. The main reason for the upgrade is using the latest signalr capabilities and hosted services. The issues we had are related to the features we use. In our case the upgrade encountered some minor issues. In this blog post I’ll show what we had to change and give some tips on how to upgrade.
When upgrading our project to the 2.1 I found that using the standard visual studio nuget manager was insufficient. The number of packages that needed an upgrade did totally crash the nuget manager. After the second try I decided that editing the package versions by hand would be far more efficient than trying to fix it with the user interface. After editing all project files I had only a few compile errors.
All ASP.NET Core and EF Core code was compiling fine with the new version. Only our signalr packges needed a small code change:
await _hubContext.Clients.Group(art).InvokeAsync("NotifyGroup", msg).ConfigureAwait(false); // Replace with: await _hubContext.Clients.Group(art).SendAsync("NotifyGroup", msg).ConfigureAwait(false);
After this all code compiled.
Our middleware handler did fail on startup with the following error:
>’An error occurred when configuring the exception handler middleware. Either the ‘ExceptionHandlingPath’ or the ‘ExceptionHandler’ option must be set in ‘UseExceptionHandler()’.’
To fix this error I made the following code change:
app.UseExceptionHandler(); // Replace with: app.UseExceptionHandler("/error");
Next we got an error in the Signalr configuration:
>System.ArgumentException: ‘The path in ‘value’ must start with ‘/’.’
This one was easy to fix:
routes.MapHub("notifications"); // Replace with: routes.MapHub("/notifications");
>System.Net.Http.HttpRequestException: Response status code does not indicate success: 405 (Method Not Allowed).
We were using the ‘@aspnet/signalr-client’ which is deprecated from now on. So we upgraded to ‘@aspnet/signalr’. This worked without any further code changes.
The next step is to use new feature of ASP.NET Core 2.1.
Run background processing in separate containers
We are planning to move our background services into there own containers by using the IHost and IHosted services:
The most important feature for entity framework for our project was the support for GroupBy. We see better query performance in these queries.
Upgrading to the new version of ASP.NET Core and Entity framework 2.1 went almost seamless. Most time was consumed by the editing the project files to change the versions. All changes we made to run the new versions where done within a day.