I'm trying to build my ASP.Net Core using a build pipeline in Azure devops and get an error when running a script to script the ef migration.
I do not have the production connection string in the appsettings.json file on purpose. The production connection string populated in the Configuration section of the app service. I know the web application can connect to the database as I have published using Visual Studio and tables have been created in the production database and also can read/save to/from the DB.
the script I'm running is:
dotnet ef migrations script -i -o $(build.artifactstagingdirectory)\scripts.sql --project $(Build.SourcesDirectory)\MyApp\MyApp.csproj --startup-project $(Build.SourcesDirectory)\MyApp\MyApp.csproj
The error in the script output is:
System.ArgumentNullException: Value cannot be null. Parameter name: connectionString
So the question I have is how can I pass the production connection string to the ef migrations command without having the connection string in the appsettings.json file?
ASPNETCORE_ENVIRONMENT=Production, and then thedotnet ef migrationscommand will handle it automatically.