17 March, 2023

ASP.NET Upgrade

Install Microsoft upgrade-assistant

dotnet tool install -g upgrade-assistant
dotnet tool install -g try-convert

# or update tool

dotnet tool update -g upgrade-assistant
dotnet tool update -g try-convert
upgrade-assistant analyze .\Teach.Server.WebAPI.Tests\Teach.Server.WebAPI.Tests.csproj
upgrade-assistant upgrade .\Teach.Server.WebAPI.Tests\Teach.Server.WebAPI.Tests.csproj

Entity Framework Migration

Replace IDbSet in DbContext with DbSet. Replace DbModelBuilder with ModelBuilder.

Newtonsoft.Json to System.Text.Json

https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to?pivots=dotnet-5-0

Controller Migration

Remove System.Web in using. Replace ApiController with ControllerBase. Replace Microsoft.AspNet.Identity with Microsoft.AspNetCore.Identity. Replace [ResponseType(typeof(Guid))] with [Produces(typeof(Guid))]. Replace async Task<IHttpActionResult> with async Task<IActionResult>.

Replace return Content(HttpStatusCode.Conflict, response); with return Conflict(response);. Configure DI registrations and remove 3rd-party DI such as Ninject.