Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ef migrations script - Unrecognized option -o error #26813

Closed
gokhancelik opened this issue Nov 24, 2021 · 5 comments
Closed

ef migrations script - Unrecognized option -o error #26813

gokhancelik opened this issue Nov 24, 2021 · 5 comments

Comments

@gokhancelik
Copy link

gokhancelik commented Nov 24, 2021

Ask a question

I am trying to generate SQL migration script with ef migrations tool in Azure DevOps Linux agent.

The same script works on my local Ubuntu machine and Windows machine.
Firstly I had a different problem. I was getting the below error message when I run the script without the export part.

Script

dotnet ef migrations script -p $(Build.SourcesDirectory)/${{ variables.migrationProjectPath }} -o ${{ variables.scriptOutputPath }} -i -v
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-ef does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
##[error]Bash exited with code '1'.
Finishing: Create migrations SQL script.

I have fixed this problem by using the export path. But now I am getting a different error. "Unrecognized option '-o /data/agents/agent-1/_work/26/a/migration.sql -i'".

Script

export PATH="$PATH:$HOME/.dotnet/tools/" && dotnet ef migrations script -p $(Build.SourcesDirectory)/${{ variables.migrationProjectPath }} -o ${{ variables.scriptOutputPath }} -i -v

Output

Starting: Create migrations SQL script.
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.178.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
export PATH="$PATH:$HOME/.dotnet/tools/" && dotnet ef migrations script -p /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj -o /data/agents/agent-1/_work/26/a/migration.sql -i -v
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /data/agents/agent-1/_work/_temp/57968963-3e94-4966-a921-8b972a5fe675.sh
Using project '/data/agents/agent-1/_work/26/s/../ProjectName.Migrations.csproj'.
Using startup project '/data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj'.
Writing '/data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpOmnQjV.tmp /verbosity:quiet /nologo /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj
Writing '/data/agents/agent-1/_work/26/s/src/.../obj/ProjectName.Migrations.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpGLl4FW.tmp /verbosity:quiet /nologo /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj
Build started...
dotnet build /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj /verbosity:quiet /nologo

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:06.05
Build succeeded.
dotnet exec --depsfile /data/agents/agent-1/_work/26/s/src/.../bin/Debug/net6.0/ProjectName.Migrations.deps.json --additionalprobingpath /home/user@domain.dom/.nuget/packages --additionalprobingpath /usr/share/dotnet/sdk/NuGetFallbackFolder --runtimeconfig /data/agents/agent-1/_work/26/s/src/.../bin/Debug/net6.0/ProjectName.Migrations.runtimeconfig.json /home/user@domain.dom/.dotnet/tools/.store/dotnet-ef/6.0.0/dotnet-ef/6.0.0/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll migrations script -o /data/agents/agent-1/_work/26/a/migration.sql -i --assembly /data/agents/agent-1/_work/26/s/.../bin/Debug/net6.0/ProjectName.Database.Migrations.dll --project /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj --startup-assembly /data/agents/agent-1/_work/26/s/src/.../bin/Debug/net6.0/ProjectName.Migrations.dll --startup-project /data/agents/agent-1/_work/26/s/src/.../ProjectName.Migrations.csproj --project-dir /data/agents/agent-1/_work/26/s/src/.../ --root-namespace ProjectName --language C# --framework net6.0 --nullable --working-dir /data/agents/agent-1/_work/26/s --verbose
Specify --help for a list of available options and commands.
Unrecognized option '-o /data/agents/agent-1/_work/26/a/migration.sql -i'
##[error]Bash exited with code '1'.
Finishing: Create migrations SQL script.

How can I solve this problem?

EF Core version: 6.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Linux (Azure Devops Agent)
IDE: None

@ajcvickers
Copy link
Member

/cc @bricelam

@bricelam
Copy link
Contributor

bricelam commented Nov 30, 2021

This looks similar to the parsing bugs (like #24251) that we saw in some of the previews. Are you sure it's using the latest versions of the .NET SDK and dotnet-ef?

@gokhancelik
Copy link
Author

gokhancelik commented Dec 1, 2021

This looks similar to the parsing bugs (like #24251) that we saw in some of the previews. Are you sure it's using the latest versions of the .NET SDK and dotnet-ef?

Yes, I am sure. .NET SDK 6.0.100 and ef migration tool is 6.0.0.

if you check "dotnet exec" command parameters you can see the versions.

@bricelam
Copy link
Contributor

bricelam commented Sep 8, 2022

I'm not able to repro this locally. @gokhancelik is it still an issue for you? If so, can you share a minimal yaml file that produces the error?

@bricelam bricelam removed this from the 7.0.0 milestone Sep 8, 2022
@ajcvickers
Copy link
Member

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants