title: How to fix: In Azure Devops connection string is null despite setting Variable in the build Pipeline
body: <p>I have problem with build pipeline in Azure Devops, with variables from build pipeline not replacing empty configuration in appsettings.json. Below there is more details.</p>
  
  <p>My current test project is build using asp.net core technology and is connected to SQL server. I also use Entity Framework Core and autofac.</p>
  
  <p>To connect to SQL server I use appsettings.json configuration:</p>
  
  <pre><code>{
    "ConnectionStrings": {
      "AzureDbConnectionString": ""
    }
  }
  </code></pre>
  
  <p>but my credentials are stored in secrets.json</p>
  
  <pre><code>{
    "ConnectionStrings": {
      "AzureDbConnectionString": "Server=tcp:servername-db-srv.database.windows.net,1433;Initial Catalog=dbname-db;Persist Security Info=False;User ID=user;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
    }
  }
  </code></pre>
  
  <p>I've configured my build pipeline variable:
  Name:</p>
  
  <pre><code>ConnectionStrings--AzureDbConnectionString 
  </code></pre>
  
  <p>Value:</p>
  
  <pre><code>Server=tcp:servername-db-srv.database.windows.net,1433;Initial Catalog=dbname-db;Persist Security Info=False;User ID=user;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
  </code></pre>
  
  <p>The problem occurs while running Generate Migration Scripts in the build pipeline.</p>
  
  <pre><code>Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Microsoft.EntityFrameworkCore.DbContextOptions[] -&gt; λ:Microsoft.EntityFrameworkCore.DbContextOptions -&gt; λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[AspNetAutofacAzure02.Data.SchoolContext, AspNetAutofacAzure02, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. ---&gt; System.ArgumentException: The string argument 'connectionString' cannot be empty.
     at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
  </code></pre>
  
  <p>Like I mentioned, it looks like the variable isn't used while generating the script.</p>
  
  <p>Is there anything wrong I do here? </p>