Unable to read connection string from app.config

オープン
#625 コメント 16 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
postgresql
領域
databases

調査の方向性

src/SQLProvider/Utils.fs から始め、特に getConStringFromConfig と、接続文字列を読み取る参照先の行を確認してください。失敗を再現するため、添付された例の docker-compose、restore、build の手順に従ってください。app.config の接続文字列を使用して provider が正常に接続し、ソースコードまたは実行時に接続文字列を要求しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

question
Description

I'm attempting to specify the connection string to my DB in an app.config file in the root of my project, instead of hardcoding it in source. The type provider throws the following error:

No connection string specified or could not find a connection string with name DefaultConnectionString

I've read through the Utils.fs file, specifically the getConStringFromConfig function. I can see that line 235 reads match config.ConnectionStrings.ConnectionStrings.[connectionStringName]. Not sure if the double ConnectionStrings is intended? That said, I've tried a few variations of nesting in my app.config file with no luck.

Repro steps
  1. Download and extract the attached example
  2. cd to root directory of example
  3. docker-compose up
  4. dotnet restore
  5. dotnet build
Expected behavior

Successful connection to DB using connection string defined in app.config.

Actual behavior

The compiler throws the following error:

No connection string specified or could not find a connection string with name DefaultConnectionString

Known workarounds
  1. Hardcode the connection string in source
  2. Provide a connection string at runtime using .GetDataContext connString (though doesn’t help where compilation needs to happen across differing environments)
Related information
  • Used database: Postgres
  • Operating system: MacOS and Windows 10 (tested on both)
  • Branch: master
  • .NET Runtime, CoreCLR or Mono Version: assuming CoreCLR - not sure how to be certain?
  • Performance information, links to performance testing scripts:

ConnectionStringTest.zip

主要言語
F#
スター
627
フォーク
147
平均マージ
2時間 2分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fsprojects/SQLProvider のほかの issue

fsprojects/SQLProvider の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。