Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Unable to read connection string from app.config

Aperta
#625 16 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql
Ambito
databases

Direzione di ricerca

Inizia da src/SQLProvider/Utils.fs, in particolare da getConStringFromConfig e dalla riga a cui si fa riferimento che legge la stringa di connessione. Segui i passaggi docker-compose, restore e build dell’esempio allegato per riprodurre il problema. Il lavoro è completato quando il provider si connette correttamente usando la stringa di connessione da app.config, invece di richiederla nel codice sorgente o a runtime.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
F#
Stelle
627
Fork
147
Merge medio
2h 2m
PR unite (30g)
1

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fsprojects/SQLProvider

Tutte le issue di fsprojects/SQLProvider

Issue simili

Altre issue su Databases

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.