Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Unable to read connection string from app.config

Đang mở
#625 16 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
postgresql
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu với src/SQLProvider/Utils.fs, đặc biệt là getConStringFromConfig và dòng được tham chiếu đọc chuỗi kết nối. Làm theo các bước docker-compose, restore và build của ví dụ đính kèm để tái hiện lỗi. Công việc được xem là hoàn thành khi provider kết nối thành công bằng chuỗi kết nối từ app.config thay vì yêu cầu chuỗi này trong mã nguồn hoặc lúc chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
F#
Star
627
Fork
147
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fsprojects/SQLProvider

Tất cả issue của fsprojects/SQLProvider

Issue tương tự

Thêm issue về Databases

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.