【发布时间】:2022-01-28 02:58:56
【问题描述】:
有谁知道为什么在从 YAML 运行 ef 迁移而不是开发人员命令提示符时需要连接字符串?
我认为这可能与未从管道变量中提取 connectionString 值有关。
我在这里设置连接字符串:
builder.Service.AddDbContext<myContext>(options=>
options.UseSqlServer(builder.Configuration.GetConnectionString("MyDB")));
我已尝试将管道变量的名称命名为
MyDB
ConnectionStrings_MyDB
ConnectionStrings:MyDB
以下 YAML 给我错误“值不能为空。(参数'connectionString')”
- task: DotNetCoreCLI@2
displayName: Create SQL Scripts
inputs:
command: custom
custom: 'ef '
arguments: migrations script --output $(sqlOutputPath) --idempotent --project $(solution)
但是,从开发人员命令提示符运行以下命令会成功执行:
dotnet ef migrations script --output complete.sql --idempotent --project myproject
【问题讨论】:
-
您是否定义了变量
sqlOutputPath和solution?如果是,您确定solution的值正确吗? -
是的,如果找不到项目,它会抛出一个项目未找到异常。
-
好吧,我问是因为您的变量建议您使用解决方案名称。你确定
solution是项目名吗? -
我很肯定,因为项目构建成功。此参数可用于解决方案和项目。
标签: entity-framework entity-framework-core yaml azure-pipelines