tag:support.appharbor.com,2010-11-23:/discussions/problems/95254-how-to-override-connection-string-in-appsettingsjsonAppHarbor: Discussion 2018-03-26T23:40:09Ztag:support.appharbor.com,2010-11-23:Comment/449538572018-03-26T23:39:34Z2018-03-26T23:40:09ZHow to override Connection string in appsettings.json<div><p>Hi,</p>
<p>How do you initialize the connection string? AppHarbor doesn't currently replace the connection strings in json files, but I think it should be possible to do in a couple of ways:</p>
<ol>
<li>Set the .NET Core environment to <code>Production</code> <a href="https://support.appharbor.com/discussions/problems/90387-is-net-core-supported-yet#comment_42832788">as described here</a>, and then <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments#environments">configure the production environment</a> to use the SQL Server add-on variable (e.g. <code>SQLSERVER_CONNECTION_STRING</code>) in that environment).<br></li>
<li>Create a Configuration Variable on AppHarbor that'll override the connection string when the app is deployed since it's injected in the environment (in all regions), so try and create a configuration variable with the name <code>ConnectionStrings:DefaultConnection</code> (replacing <code>DefaultConnection</code> with the actual name of the connection string in your <code>appsettings.json</code> file) and the connection string as the value.</li>
</ol>
<p>Let me know if either of those approaches doesn't work!</p>
<p>Best,<br>
Rune</p></div>rune