What happens in the ConfigureServices method?

Beginner

Answer

ConfigureServices is where you register application services with the dependency injection container. This can include framework services (MVC, Razor Pages, Entity Framework) and custom application services.

Example:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
}