AddIdentity() fails “InvalidOperationException: Scheme already exists: Identity.Application”

前端 未结 7 707
闹比i
闹比i 2021-01-07 22:05

I\'m trying to add facebook login to my .NET Core 2.1 site

I\'m following this , guide and more specific, this (for facebook login)

After have adding the lines

7条回答
  •  盖世英雄少女心
    2021-01-07 22:26


    I had the same issue, I was registering services in two different files in the same time: Startup.cs and IdentityHostingStartup.cs files.

    What I did?

    I sepeprated registering the services in both files as following:

    IdentityHostingStartup.cs

    I only registered Identity DB Context in this file:
    //lets register identity db context builder.ConfigureServices((context, services) => { services.AddDbContext(options => options.UseSqlServer( context.Configuration.GetConnectionString("IdentityDBConnection"), x => x.MigrationsAssembly("WebApplication1") ) );

    Startup.cs

    In this file I registered DefaultIdentity, Roles and EntityFrameworkstores
    //I registered the DefaultIdentity, the Roles and the EntityFrameworkstores services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) .AddRoles().AddEntityFrameworkStores();

提交回复
热议问题