In my case (VS2022, .NET 6) I also encountered the same problem n got solution in following way;
- Added Connection String in appsettings.json file (Screenshot attached)
 - Ran the command: PM> Scaffold-DbContext name=StudentDbConnectionString TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
 - It generated relevant DbContext file (Screenshot attached)
 - Manually registered DbContext in Builder.Services in program.cs…
 
    
Top comments (0)