Scaffold-DbContext to different output folder

前端 未结 5 1364
日久生厌
日久生厌 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:42

    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.

提交回复
热议问题