ASP.NET Core 6 Identity - Scaffolding Identity problem

AlexD 6 Reputation points
2022-06-27T19:31:58.127+00:00

I am following the tutorial on learn.microsoft.com (Authentication, ASP.NET Core 6.0).

I create ASP.NET Core Web App with individual user accounts and update a database. So far everything works. Then I scaffold the identity.

Then I Scaffold Register, Login, LogOut, and RegisterConfirmation according to the tutorial. Here I select "Login", "Logout" etc., select ApplicationDbContext as Data Context Class and click add.

The problem is that in program.cs it generates additional connection string (so there are two of them), as well as dublicates of builder.Services.AddDbContext... and builder.Services.AddDefaultIdentity...

Everything works fine if I delete (comment out) this newly generated lines but I do not know what am I doing wrong.

Developer technologies ASP.NET ASP.NET Core
{count} vote

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-06-28T01:59:06.617+00:00

    Hi @AlexD ,

    The problem is that in program.cs it generates additional connection string (so there are two of them), as well as dublicates of builder.Services.AddDbContext... and builder.Services.AddDefaultIdentity...

    Everything works fine if I delete (comment out) this newly generated lines but I do not know what am I doing wrong.

    I could reproduce the problem on Asp.net 6 application and use VS 2022. This error appeared recently and only on Asp.net 6, it does not happen on the Asp.Net 5 and the previous version. And I found this issue has been feedback to the Asp.net development team, you can check it and wait the response.

    As a temporary solution, as you said you can delete or comment out the duplicate lines. Or you can create an Asp.net 5 or previous version application.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.