0

I'm making a .NET Core console application using VS 2019. I use EF Scaffolding using de NuGet console. In a MVC project I use the following command:

Scaffold-DbContext Name=ConnectionStrings:ClientConnection ....

Note that I use the alias that exists in the appesetting.json so that I don't explicitly put the database credentials in the command (for good practices purposes). Anyway this works in a MVC project as I said, but in a console app it does not accept the alias, I get the following error:

"A named connection string was used, but the name 'ConnectionStrings:ClientConnection' was not found in the application's configuration. Note that named connection strings are only supported when using 'IConfiguration' and a service provider, such as in a typical ASP.NET Core application. See https://go.microsoft.com/fwlink/?linkid=850912 for more information."

I have to explicitly add the connection string with everything so that it works.

How can I use the scaffold command using the "Name=ConnectionStrings:ClientConnection" without any problem in a .NET Core Console Application?

Luis Frediani
  • 83
  • 1
  • 1
  • 6

0 Answers0