I know that almost all the other answers recommends to change the target framework, but some users (including me) needs to use .NET 6.0
instead of .NET Framework
, so that solution its not valid for us.
I was able to create the models by using Paul Sinnema’s link and using SQL authentication instead of Windows Auth (in my case):
You will need to install the following packages from NuGet:
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
Afted that run the following command in the Package Manager Console:
(Tools>Nuget Package Manager>Package Manager Console)
PM> Scaffold-DbContext "Server=.\LOCAL_SERVER;User ID=YOUR_DB_USER;Password=YOUR_DB_PASSWORD;Database=YOUR_DATABASE;Trusted_Connection=False;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models