dotnet / dotnet/AspNetCore.Docs

Asp.net 6 scaffold identity generates additional connection string and register dbcontext and identity twice

Open
#26,241 4 comments 3 reactions 0 assignees View on GitHub
Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

I create ASP.NET Core Web App with individual user accounts, Then i scaffold identity, Here i select Register, Login, LogOut, and RegisterConfirmation, Then i select ApplicationDbContext as Data Context Class and click add.

![image](https://user-images.githubusercontent.com/83857035/176070086-17fa8874-0c5e-40ea-8b71-e7ac99f8944c.png)

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...

![image](https://user-images.githubusercontent.com/83857035/176070012-3807a089-a71c-4cc5-a709-1570b910a157.png)

I try this steps in asp.net core 3.1 and it will not show the same situation as .net 6

The version of my VS is Visual Studio Community 2022 (17.1.6).

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 804e24dd-7e30-8cf5-2c99-1ffacb4582f6
* Version Independent ID: 3e25547b-e2c9-6634-2c38-2a77207f17d4
* Content: [Scaffold Identity in ASP.NET Core projects](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=visual-studio)
* Content Source: [aspnetcore/security/authentication/scaffold-identity.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/authentication/scaffold-identity.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-security**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.