Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I updated my .NET CORE project from 2.1 to 3.1, yet I have some errors in the class Startup

I just updated my version of .NET CORE. I already updated all the usings however I still have an error in the satrtup class, in the method ConfigureServices, when adding the default identity. It just gives me an error saying "'IServiceCollection' does not contain a definition for 'AddDefaultIdentity and no accessible extension method 'AddDefaultIdentity...'". Here is the method:

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
    });

    services.AddDbContext<ApplicationDbContext>(options =>
       options.UseSqlServer(     
           Configuration.GetConnectionString("DefaultConnection")));

    //ERROR
    services.AddDefaultIdentity<IdentityUser>()
        .AddEntityFrameworkStores<ApplicationDbContext>();

    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

    //SIGNAL R
    services.AddSignalR();
}

I also have an error in the Configure method.

  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            //ERROR
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }
       //MORE CODE
  }

What should I do to solve this error?

like image 452
Teresa Alves Avatar asked Mar 12 '20 17:03

Teresa Alves


People also ask

Is .NET Core 3.1 still supported?

NET Core 3.1 was originally released on December 3, 2019 and is supported for three years. But the actual end of support day will be the closest Patch Tuesday starting that date, which is December 13, 2022.


1 Answers

Those two extension methods have moved into separate NuGet packages, which must be referenced explicitly in ASP.NET Core 3.0 and upwards:

Method Package
AddDefaultIdentity Microsoft.AspNetCore.Identity.UI
UseDatabaseErrorPage Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
like image 72
Kirk Larkin Avatar answered Oct 12 '22 13:10

Kirk Larkin