BLANK, NULL AND BLACK

ASP.NET Core는 connectionString을 appsettings.json 파일에 저장해서 사용할 수도 있다고 한다.

 

  "ConnectionStrings": {
    "SQLiteDatabase": "Data Source=./Database/NorthWind.sqlite;"
  }

 

이것을 데이터베이스와 통신하는 클래스나 메서드에서 사용해야 하는데 어떻게 호출하는지 난감했음.

 

https://www.aspsnippets.com/Articles/Net-Core-Read-Connection-String-from-AppSettingsjson-file.aspx

 

.Net Core: Read Connection String from AppSettings.json file

Here Mudassar Ahmed Khan has explained with an example, how to read Connection String from AppSettings.json file in .Net Core and ASP.Net MVC Core. Microsoft has replaced System.Configuration class with IConfiguration interface in .Net Core 2.0. TAGs: ASP.

www.aspsnippets.com

Controller에서 Connection 객체를 만들어 서비스를 호출할 때 파라미터로 ConnectionString을 던져주는 방법을 사용하는데 더 효율적인 방법이 있는지 궁금하다.