0

At my company everyone uses Windows. We have some template projects that we use when developing for clients. I dislike working on Windows, so I use a Mac, which causes a problem.

All template projects here have been setup to use LocalDB as SQL server in the appsettings.json file. LocalDB is Windows-only, thus I want to use a Docker container with MSSQL instead.

I want to be able to change the connection string without changing the appsettings.json file, as it would cause problems with all other developers on the project (who uses Windows).

{
  "ConnectionStrings": {
    "Connect": "Server=(localdb)\\mssqllocaldb;Database=Connect;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
}

I want to use the following connection string:

Server=127.0.0.1,1433;Database=Connect;User Id=SA;Password=mySecur3!Password
Algorythm
  • 130
  • 9
  • You could add a second appsettings.{environment}.json file which is not included in source control, and use it to override the original connection string, like this: https://stackoverflow.com/a/46364665/1398649 – Marc Brekoo May 07 '19 at 09:14

3 Answers3

1

When it comes to storing secrets i would recommend to use secrets.json as described here: Safe storage of app secrets in development in ASP.NET Core

secrets.json is a file on each local computer that is not checked in.

Daniel
  • 9,491
  • 12
  • 50
  • 66
0

As mentioned above .net core support multiple json files. one for each environment, You can read more here: https://aspnetcore.readthedocs.io/en/stable/fundamentals/environments.html

itsikha
  • 82
  • 11
0

You can use a local environment configuration file appsettings.local.json which can be added into .gitignore to not cause any trouble to others. You can read this from a similar issue: https://stackoverflow.com/a/49658455/8714866

Fragezel
  • 1
  • 1