I\'m implementing repository pattern in company solution I work for, separating model classes in a Backend project and database context and migrations in DbContexts project.
I faced a similar problem. I had my EF models in a separate project. In order to write the models there, I just used the following command:
Scaffold-DbContext "Server=[Server];Database=[Database Name];Trsted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -Project "[Project Name]" -Force
The key for me was the -Project "[Project Name]" -Force
option.
As the top answer indicates, if you want a different folder within that project, you can just use the -OutputDir
option.