You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support working with appsettings.json in Asp.Net Core 2.x and above #370
In core there has been a shift away from web.config files and to using appsettings.json to hold configuration settings. It would be ideal if these configuration files could be used with type providers.
Repro steps
Build an asp.net core application
Configure trivial type provider that references the name of the connection string in appsettings.json
Build applicaiton
Expected behavior
The expected behavior is for the type provider to be able to locate the connection string in the config file.
Actual behavior
The connection string cannot be found and the application will not build.
Good news — I've opened a draft PR that adds appsettings.json support to DesignTimeConnectionString: this run's PR (see the Monthly Activity issue #449 for the link once it's created).
What the PR does:
When no app.config or web.config is found, ReadFromConfig now auto-discovers appsettings.json (and appsettings.Development.json) in the resolution folder, reading from the standard ConnectionStrings section:
You can also pass appsettings.json explicitly as the ConfigFile parameter: ConfigFile = "appsettings.json".
The error message when no config file is found now mentions appsettings.json and the ConfigFile parameter.
Limitation: The runtime connection string lookup still uses System.Configuration.ConfigurationManager, which does not read appsettings.json. So at runtime in ASP.NET Core you should either:
Pass the connection string via the connection constructor parameter (injected from IConfiguration), or
Use a literal connection string at design time (pointing to a dev DB) and inject the production string at runtime.
This PR unblocks the design-time compilation step that was preventing ASP.NET Core projects from using name=... syntax at all.
Activity
smoothdeveloper commentedon Jan 27, 2020
@rahicks26 is it something you'd like to contribute in a PR?
I haven't used new ASP.NET stuff.
To make the changes in the library, one would have to
NameInConfigis used in the library: https://github.com/fsprojects/FSharp.Data.SqlClient/search?q=NameInConfig&unscoped_q=NameInConfigI'd be happy to review and merge such PR.
rahicks26 commentedon Jan 28, 2020
@smoothdeveloper yeah that sounds fun. I will take a look this weekend and see what I can make of it.
github-actions commentedon Mar 14, 2026
🤖 This is an automated response from Repo Assist.
Good news — I've opened a draft PR that adds
appsettings.jsonsupport toDesignTimeConnectionString: this run's PR (see the Monthly Activity issue #449 for the link once it's created).What the PR does:
app.configorweb.configis found,ReadFromConfignow auto-discoversappsettings.json(andappsettings.Development.json) in the resolution folder, reading from the standardConnectionStringssection:{ "ConnectionStrings": { "MyDb": "Server=.;Database=MyApp;Integrated Security=True" } }appsettings.jsonexplicitly as theConfigFileparameter:ConfigFile = "appsettings.json".appsettings.jsonand theConfigFileparameter.Limitation: The runtime connection string lookup still uses
System.Configuration.ConfigurationManager, which does not readappsettings.json. So at runtime in ASP.NET Core you should either:connectionconstructor parameter (injected fromIConfiguration), orThis PR unblocks the design-time compilation step that was preventing ASP.NET Core projects from using
name=...syntax at all.feat: add appsettings.json support to DesignTimeConnectionString (Closes