Application upgrade
.NET Core ASP.NET Core Identity C# Entity Framework Core OpenAPI Swagger Visual Studio Web API

How to Migrate from a .NET Core 2.0 Web API to .NET Core 3.1 (Part 3)

Welcome to today’s post.

Today I will be continuing with the second part of my series on showing how we can migrate from an existing ASP.NET Core 2.0 Web API application to an ASP.NET Core 3.1 Web API application.

In the previous post, I showed how to migrate the following features from .NET Core 2.0 to 3.1:

  1. OData packages.
  2. Swagger (Open API) packages.

In my first upgrade post, I showed how to apply the following migrations:

  1. Migrating of ASP.NET Core packages.
  2. Updating Entity Framework Core packages.
  3. Updating JSON Token security packages.
  4. Updating Entity Framework Core for SQL Server.
  5. Updating MVC Endpoint Routing.
  6. Endpoint Routing for Controllers with Attribute Routing.
  7. Update to JSON Formatting
  8. Discussion of the HTTP 500 error.

This post is an extension to our previous two posts.

In this post I will be discussing how to upgrade packages for the following features of .NET Core 3.1:

  1. Updating ASP.NET Core Identity packages.
  2. Entity Framework Core SQL Server extensions.
  3. Additional notes on Swagger (Open API) types.

As I mentioned in the previous post, the upgrades I have been explaining from the previous post and from this post can also be applied to upgrade an ASP.NET Core web application.

The first section will be very brief and will mention packages that are required for upgrades of ASP.NET Core Identity.

Updates for ASP.NET Core Identity

In ASP.NET Core Identity, to use the IdentityUser type we will need the installation of the NuGet package Microsoft.AspNetCore.Identity v2.2.0. To use the IdentityDbContext, RoleStore and UserStore types, the packages Microsoft.AspNetCore.EntityFrameworkCore v3.1.0 and  Microsoft.AspNetCore.Identity.EntityFrameworkCore v5.0.2.

Updates for Swagger Annotations and Types

To use IOperationFilter and Operation attributes in Swagger install package: Swashbuckle.AspNetCore.Annotations v5.0.0.

Enabling Swagger annotations is configured in ConfigureServices():  

services.AddSwaggerGen(c =>

This is needed when using the parameters OpenApiOperation and OperationFilterContext within the IOperationFilter method:

public void Apply(OpenApiOperation, OperationFilterContext)

The new Swagger OpenAPI types can be used with the following replacements:

Replace type Operation with OpenApiOperation.

Replace type Response with OpenApiResponse.

Replace type IParameter and NonBodyParameter with OpenApiParameter.

The replacement of hardcoded types in OpenApiParameter definitions. For example, the replacement of the string type:

Replace type = “string”


Schema = new OpenApiSchema { Type = "String" } 

An example of where this is replacement applies is here:

operation.Parameters.Add(new OpenApiParameter
    Name = "Authorization",
    In = ParameterLocation.Header,
    Description = "JWT access token",
    Required = true,
    Schema = new OpenApiSchema { Type = "String" }

Entity Framework Core SQL Server extensions

To enable the extension method UseSqlServer() for type DbContextOptionsBuilder install the

NuGet package Microsoft.EntityFrameworkCore.SqlServer v3.1.0. This is commonly used when we are defining connection strings in our startup:

services.AddDbContext<ApplicationDbContext>(options => 

After the above packages have been applied, our installed packages should look as follows:

After building and running our .NET Core 3.1 Web API that uses ASP.NET identity, the resulting Swagger screen will display as shown:

That’s all for today’s post and completes our series on upgrading a Web API from .NET Core 2.0 to 3.1.

I hope you found this post useful and informative.

Social media & sharing icons powered by UltimatelySocial