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 answers
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
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
- Windows environment variables at appsettings.json
- How to default to not use appsettings.Production in .Net
- ConfigurationBuilder.AddJsonFile uses wrong json file every other time
- How to overwrite appsettings.json in WebApplicationFactory?
- How to read a single value from appsettings.json containing collections
- Query regarding overlay view not working on Settings
- Missing file from installed app with Windows Packaging Project
- How to dynamically Change appsettings.json Based on Build Configuration in .NET
- Protect appsettings.json in net core
- App permission in flutter - "Allow Display over other apps"
- How to setup and read appsettings when creating a project in Visual Code?
- Web.config transform not being performed in .NetCore 6 webapi service
- How to read nested objects from appsettings?
- .NET Blazor MAUI Hybrid App - Add appsettings.json
- appsettings.json is not loaded .net 8 blazor web assembly
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?
Popular Tags
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)
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: