How to override Connection string in appsettings.json
I have an asp.net core 2.0 web application worked fine at local sql server.
After publishing i become error:
Win32Exception: The network path was not found
Unknown location
SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I set up connectionstring alias as described here: https://support.appharbor.com/kb/add-ons/using-sequelizer (this worked fine for my classic asp.net apps on appharbor)
Also I read again this topic: https://support.appharbor.com/discussions/problems/90387-is-net-cor... - user AHRocks told 'create Web.Config and inject this config into IHostingEnvironment'), but..
it also doesn't work: appharbor inject in web.config (i tried also Web.config - is file name case-sensitive?) some strings (system.webserver) but it can't see connectionString.
I'm puzzled. What is the right way?
It looks like that .net core at EU servers still has no injection: https://support.appharbor.com/discussions/problems/90851-net-core-c...
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by rune on 26 Mar, 2018 11:39 PM
Hi,
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:
Production
as described here, and then configure the production environment to use the SQL Server add-on variable (e.g.SQLSERVER_CONNECTION_STRING
) in that environment).ConnectionStrings:DefaultConnection
(replacingDefaultConnection
with the actual name of the connection string in yourappsettings.json
file) and the connection string as the value.Let me know if either of those approaches doesn't work!
Best,
Rune