I have couple of console apps which have the same key in appsettings.json (ConnectionString). I need to centralise these connection strings on the machine. The best place I can think of to use Environment Variables. These both console apps need to target different databases. I need a way to set key values to different databases. If this was an IIS application then I could use location tag in applicationhost.config to set different values for them. Can similar approach be used for console apps?
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in CONSOLE-APPLICATION
- C# Console app do not exit until CTRL+C pressed without while loop
- Time usage saved from a process is not properly stored/shown
- Is it safe to integrate with SharePoint online API through a console application which is hosted on local VM
- How to publish .NET Core console application with particular profile?
- Protected .pyd not working with debug mode in c# sharp console application
- .NET 8 Console App DI Error 'Unable to resolve service for type 'Microsoft.Extensions.Logging.ILoggerFactory'
- Why is my cursor in a random far-away place in Visual Studio Debug Console
- I'm trying to write a simple program that picks a random number between 1 and 10 and gives the user to guess it
- Accessing DI elements like IConfiguration from within nested class in a Core console app
- Is it possible to listen for console input from a C# Windows Application?
- Win32 Console Application Unexpectedly Terminates with Code 58
- Conway's Game of Life: unexpected behavior
- .NET Core console application crashes on debug
- How to tell a program to clear the console in python
- Create docker Img from .NET Core (Console APP) that creates output file is not creating files with docker run
Related Questions in APP-CONFIG
- How to bind list of Enviroment Variables to Options in .NET
- Set & use variable name in app service configuration that doesn't exist in web.config
- Automatic binding redirection replacing the entire App.config file
- GetLatest Value from AppConfig using terrafrom
- how to save printer name configuration in appSettings from PrinterSettings looping in combobox in vb.net
- Is it possible to have different configuration set for the same key for multiple console apps on windows?
- Custom Config Section Property C#
- JSON library version mismatch
- Nlog configuration for .net 4.8 Console application to write to DB - No logs written
- C# Windows Form: pragmatically edit/update an Array of strings in resulting App.Config file
- Can I remove BindingRedirects from app.config c#/visual studio 2019?
- GetConnectionString using IHostBuilder
- Dll Config not being recognized
- Azure Function App AzureWebJobsStorage vs WEBSITE_CONTENTAZUREFILECONNECTIONSTRING
- Error in Exporting an RSA Key Container for Encrypt app.config in C# Window Application
Related Questions in APPSETTINGS
- Getting a list of installed VPN Profiles Programatically - iOS
- AppSettings.json for Integration Test in ASP.NET Core
- ConfigurationErrorsException when adding log4net configuration to the app.config
- Can't modify app.config file with no error
- Elmah not catching WebConfigurationManager.AppSettings[""].ToString() Exception in C#
- cdata in appSettings value attribute
- Is it safe to store appSettings programmatically from appSettings web.config
- Asp.net Mvc centralised app settings?
- iOS custom keyboard settings not saving
- How to read configuration (appsettings) values inside attribute in .NET Core?
- Can't read appsettings.json without DI due to missing Configuration Builder
- C# AppSettings array
- @PropertySource @Value static strings return null
- Reading and Writing keys to appsettings in WebConfigEditor
- How do I use the app settings of a class library?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
And
You need to either implement some magic by hand - for example you can store connection string name in
appsettings.json:and the connection string itself in appropriately named environment variable -
ConnectionStrings__App1ConnectionStringandConnectionStrings__App2ConnectionStringaccordingly. And in the app you will do something like:But since you are using
Process.Startyou can pass the connection string as a parameter for your app. For example in the app:And on the calling side provide the parameter - something like: