0

I was using .NET 5 and I wrote this line of code in Startup.cs

var host= CreateHostBuilder(args).Build();
host.MigrateDatabase<Program>();
host.Run();

but now I don't know how should I use this in .NET 6 at Program.cs

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
DeV1
  • 247
  • 1
  • 3
  • 9

1 Answers1

2

.NET 6 has introduced the new minimal hosting model for ASP.NET Core apps. In short you can summarize the changes to the following:

var builder = WebApplication.CreateBuilder(args);

// Here goes code from Startup.ConfigureServices

var app = builder.Build();

// Here goes code from Startup.Configure

app.Run();

For more details check the:

Note that the "old" generic host model (ASP.NET Core version) still exists, works and can be used (actually some templates like worker one still use it).

Guru Stron
  • 102,774
  • 10
  • 95
  • 132