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

前端 未结 7 631
闹比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:27

    This is a change from .Net Core 2.0->2.1, I guess the guide hasnt been updated.

    After stumbling upon this SO post I : Removed the lines entire services.AddIdentity()...call (all 3 lines) (but of course kept the AddDefaultIdentity()-call that was there before

    Changed back in ApplicationDbContext.cs from

    public class ApplicationDbContext : IdentityDbContext
    

    to

    public class ApplicationDbContext : IdentityDbContext
    

    ... So if your starting out from scratch (new .Net Core 2.1-template), all you have to do is add lines

         services.AddAuthentication().AddFacebook(facebookOptions =>
            {
                facebookOptions.AppId = Configuration["...FacebookLogin:AppId"];
                facebookOptions.AppSecret = Configuration["...FacebookLogin:ClientSecret"];
            });
    

    from the tutorial.

    At least this "fix" takes me through so far that the users can register, havent investigated where my "ApplicationUser" went (in case/when I want to add more user-properties)...since there is no reference to it anymore

提交回复
热议问题