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