Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold-DBContext fails when Database connection string is moved to secrets.json in efcore 9.0.1 and 9.0.2 #35641

Open
ruhar opened this issue Feb 16, 2025 · 0 comments

Comments

@ruhar
Copy link

ruhar commented Feb 16, 2025

Bug description

Scaffold-DBContext works when database connection is setup in appsettings.json in all versions tested. 8.0.8-9.0.2. When moving the database connection to secrets.json, the Scaffold-DBContext command works as expected in versions 8.0.8-9.0.0. I receive a Database Connection was not found in the applications configuration error in versions 9.0.1 and 9.0.2. Rolling the Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityrameworkCore.Tools back to version9.0.0 or earlier, Scaffold-DBContext command works using secrets.json.

Your code

Package Manager Console command:
Scaffold-DbContext -Connection Name=ConnectionStrings:DatabaseConnection -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context ApplicationDbContext -Force -ContextDir ./Data -NoOnConfiguring

secrets.json:
{
  "ConnectionStrings:DatabaseConnection": "Data Source=powerdb.test.com;Initial Catalog=TemplateDB;Persist Security Info=True;User ID=template;Password=**********;Trust Server Certificate=True"
}

Stack traces


Verbose output


EF Core version

9.0.2

Database provider

No response

Target framework

.NET 8.0

Operating system

Windows 11

IDE

Visual Studio 2022 v17.4

@ruhar ruhar changed the title Scaffold-DBContext fails when Database connection is moved to UserSecrets.json 9.0.1 and 9.0.2 Scaffold-DBContext fails when Database connection string is moved to secrets.json in efcore 9.0.1 and 9.0.2 Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant