ASP Core Cannot Set User Secrets in VS 2017

In VS Code 2019, you can use the command below to generate the UserSecret section within your csproj file. Please make sure you are within the directory containing the desired csproj file when running the command.

dotnet user-secrets init

I got the same error and I fixed it by generating a new UserSecretsId.

The UserSecretsId will be generated automatically if you right click on the Project in the Solution Explorer and press Manage User Secrets.