DEV Community

Shafiq Ur Rehman
Shafiq Ur Rehman

Posted on

Answer: Use name connectionStrings in app.config for Scaffold-DbContext EF 6 command

In my case (VS2022, .NET 6) I also encountered the same problem n got solution in following way;

  1. Added Connection String in appsettings.json file (Screenshot attached)
  2. Ran the command: PM> Scaffold-DbContext name=StudentDbConnectionString TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
  3. It generated relevant DbContext file (Screenshot attached)
  4. Manually registered DbContext in Builder.Services in program.cs…

Top comments (0)