Search code examples
.net-core

Placing dotnet scaffolded files in Models folder


I successfully executed:

dotnet ef dbcontext scaffold "Host=myDbServer;Database=profiles_editor_data;Username=myUsername;Password=mypassword" Npgsql.EntityFrameworkCore.PostgreSQL

However, this cmd places the classes files in my project's root folder. Is there a way to force it to place all these files in the Models folder?


Solution

  • The documentation has a section "Target directories and namespaces", which explains the option you would use to put the scaffolded files in whatever directory you wish.

    You can try the following command:

    dotnet ef dbcontext scaffold "Host=myDbServer;Database=profiles_editor_data;Username=myUsername;Password=mypassword" Npgsql.EntityFrameworkCore.PostgreSQL --output-dir Models