5

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?

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
Teresa Alves
  • 483
  • 1
  • 7
  • 16
  • When I recently migrated a webapi app from .net core 2.2 to 3.1, I ran into issues with some changes to namespacing and making sure my `app.use` statements were in the correct order. The Microsoft migration guides were super helpful - you might try starting there. Here are the links: https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-3.1&tabs=visual-studio https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio https://docs.microsoft.com/en-us/aspnet/core/migration/30-to-31?view=aspnetcore-3.1&tabs=visual-studio – Chris Brenberg Mar 12 '20 at 17:45
  • Did you follow the migration guides? [2.2 -> 3.0](https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30), [3.0 -> 3.1](https://learn.microsoft.com/en-us/aspnet/core/migration/30-to-31) – Joelius Mar 12 '20 at 17:46

1 Answers1

12

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
Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203