Passing from .NET 5 to .NET 6
First, read the document here: Migrate from ASP.NET Core 5.0 to 6.0 | Microsoft Docs .\
So those were my steps ( fully compile after each step ):
1. Replace in csproj net5.0 with net6.0
<TargetFramework>net6.0</TargetFramework>
2. Update all nugets reference to the latest version
3. Add globals.cs with various usings
4. Add globals.cs . Mine looks this way ( without the necessary for the project)
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading.Tasks;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.ApiExplorer;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Options;
global using Microsoft.OpenApi.Models;
global using Swashbuckle.AspNetCore.SwaggerGen;
global using Microsoft.AspNetCore.Builder;
global using AMSWebAPI;
global using appSettingsEditor;
global using HealthChecks.UI.Client;
global using Hellang.Middleware.ProblemDetails;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.AspNetCore.HttpOverrides;
global using NetCore2BlocklyNew;
5. Move away from Startup – put all in program .cs – easy : services moved to app.Services , and instead of parameters in configure, use the app.Services – example
var provider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
6. Tests
I have a problem with “ The server has not been started or no web application was configured. “ -when I configure WebApplicationFactory<Program>
Reading Minimal APIs in .NET 6 but where are the Unit Tests? – Scott Hanselman’s Blog
Testing in .NET 6 with WebApplicationFactory (including Minimal APIs) | by Lee Dale | Medium
Integration tests in ASP.NET Core | Microsoft Docs
No avail yet. Should study ore.
Leave a Reply