I am working on .NET 5 Web API in which I have several projects in one solution. One project is for only controllers, another one I have added as class library project for interfaces, third project is also class library project for models which I would need to create it from existing DB using EF core. Fourth project is again class library project where I will write data manipulation logic using EF core. As most of the online tutorials are using Code first approach so I am little bit stuck for my DB first approach. Since I am doing this 1st time. I have few questions.
Scaffold-DbContext "Server=.;Database=BookStore;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer
Its creating context classes in API project instead of DTO project. How can I create models in DTO project.
Open the Package manager console and select DTO from the dropdown. Run the following command. Make sure your directory must be there to import models into
Scaffold-DbContext "Server=.;Database=PalletPal_LicenseStore;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir YourModelDirectory -Force