在VS2019、C#、EF6上,使用Package控制台,我试图根据这个链接为Add-Migration命令指定-OutputDir,但它总是写入项目的根目录。如果删除-OutputDir参数,它将在\Migrations文件夹中写入,但我更喜欢在\Migrations\MySubFolder中
PM> add-migration -name CreateInitialTables -OutputDir \Migrations\MySubFolder -context MyDbContext发布于 2021-03-17 16:58:11
来自Add-Migration的文档
-OutputDir :用于输出文件的目录。路径相对于目标项目目录。默认为“迁移”。
因为路径是相对的,所以需要指定没有前导斜杠的路径,或者使用.\来指示当前目录。例如:
add-migration -name CreateInitialTables -OutputDir .\Migrations\MySubFolder -context MyDbContext发布于 2022-09-09 09:30:54
对于使用dotnet ef migrations命令的人,您可以使用--output-dir参数来执行此操作。
来自dotnet ef migrations add --help
...
Options:
-o|--output-dir <PATH> The directory to put files in. Paths are relative
to the project directory. Defaults to "Migrations".
...例如:
dotnet ef migrations add InitialCreate --context MyContext --output-dir Migrations\MyContexthttps://stackoverflow.com/questions/66677334
复制相似问题