'How can I use DB first approach in .NET Core 6?

I try to use Entity Framework in a minimal API running in a .NET Core 6 project. As far as I understand I should run dotnet ef dbcontext scaffold xxxx which I do, I don't get any errors but no models are added to my project.

Can someone please explain how I can use DB first approach with CRUD functionality?



Solution 1:[1]

You should use Frameworks as Microsoft.NETCore.App

Packages from NuGet Package Manager

  1. Microsoft.EntityFrameworkCore
  2. Microsoft.EntityFrameworkCore.SqlServer

Now you can run the command:

Scaffold-DbContext "Server=10.10.10.123;Database=Testdb; user id=sa; password=Sa1234" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context TestDBContext -Tables employee

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dutt93