0

在具有迁移的 ASP.NET Core 应用程序中,运行更新数据库会提供以下输出。它有效,详细输出显示各种选项的默认值。

dotnet ef --verbose database update 

Setting the data directory to 'C:\temp\bin\Debug\netcoreapp1.0\'.
Invoking dependency command 'Microsoft.EntityFrameworkCore.Design' in project '2016-101DP-TreeGame-Auth'
Running C:\Program Files\dotnet\dotnet.exe exec 
  --runtimeconfig C:\temp\bin\Debug\netcoreapp1.0\temp.runtimeconfig.json
  --depsfile C:\temp\bin\Debug\netcoreapp1.0\temp.deps.json 
  --additionalprobingpath C:\Users\me\.nuget\packages C:\Users\me\.nuget\packages\Microsoft.EntityFrameworkCore.Design\1.0.0-preview2-final\lib\netcoreapp1.0\Microsoft.EntityFrameworkCore.Design.dll 
  --assembly C:\temp\bin\Debug\netcoreapp1.0\temp.dll 
  --startup-assembly C:\temp\bin\Debug\netcoreapp1.0\temp.dll 
  --dispatcher-version 1.0.0-preview2-21431 
  --data-dir C:\temp\bin\Debug\netcoreapp1.0\ 
  --project-dir C:\temp 
  --content-root-path C:\temp
  --root-namespace temp
  --verbose update database
Process ID: 12544
Finding DbContext classes...
Using context 'ApplicationDbContext'.
Done.

当我尝试使用选项运行相同的命令时,CLI 抱怨我的选项具有“意外值”。这里有两个例子。

dotnet ef --data-dir C:\temp\bin\Debug\netcoreapp1.0\ --verbose database update

dotnet ef --data-dir "C:\temp\bin\Debug\netcoreapp1.0\" --verbose database update

两者都告诉我:

Microsoft.Extensions.CommandLineUtils.CommandParsingException:选项“data-dir”的意外值“C:\temp\bin\Debug\netcoreapp1.0\”

在 Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)

在 Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)

命令的期望值的规则是什么dotnet ef

4

1 回答 1

1

有两层。dotnet-ef从项目中读取元数据(并构建它),然后ef使用该元数据(包括输出程序集路径)进行调用。您无法指定以下选项,dotnet ef因为它们是为您确定的。

  • --assembly
  • --startup-assembly
  • --data-dir
  • --project-dir
  • --content-root-path
  • --root-namespace

中显示的其余选项dotnet ef --help可以在 上指定dotnet ef

作为问题#6592的一部分,这应该会变得更好。

这是一些关于 dotnet ef 的文档

于 2016-11-07T21:54:05.310 回答