After upgrading to .Net 5, my entity framework web app throws an error when hitting the default controller

Solution for After upgrading to .Net 5, my entity framework web app throws an error when hitting the default controller
is Given Below:

I recently upgraded a .Net Core 2 Entity Framework web app to the latest .Net5.

I had to fix a ton of things to get it to build successfully. After finally getting it to build, when I try to run it locally in visual
studio, I get this error:

  Message=No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has been registered.
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Mvc.Controller.get_TempData()
   at Microsoft.AspNetCore.Mvc.Controller.View(String viewName, Object model)
   at Microsoft.AspNetCore.Mvc.Controller.View(String viewName)
   at Microsoft.AspNetCore.Mvc.Controller.View()
   at LET.Panopto.Scheduler.Controllers.HomeController.Index() in G:GamerModsEFStart.AspNetCore.GamerModControllersHomeController.cs:line 17
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

It looks like the error originates in my HomeController.cs file here:

    public IActionResult Index()
        return View();

In my Startup.cs file, during the upgrade I had to change this:

    app.UseMvc(routes =>
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");

to this:

app.UseEndpoints(endpoints =>
    endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");

It doesn’t seem like a lot of people get this error, and the only one that people said worked was this:

 services.AddMvcCore(options => options.EnableEndpointRouting = false).AddRazorViewEngine();

But I don’t use Razor pages.

So I can’t figure out why it’s complaining. It worked fine before my .Net5 upgrade.

Has anyone encountered this?