Scaffold-DbContext to different output folder

前端 未结 5 1464
日久生厌
日久生厌 2021-01-11 13:02

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.

5条回答
  •  难免孤独
    2021-01-11 13:29

    It is now possible to redirect the generated context with -ContextDir option:

    -ContextDir The directory to put DbContext file in. Paths are relative to the project directory.

    So in your case it would be something like this:

    Scaffold-DbContext "*connection*" "*provider*" -OutputDir "BackendProject" -ContextDir "DbContexts"
    

    Source: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell

提交回复
热议问题