Skip to content

Add support working with appsettings.json in Asp.Net Core 2.x and above #370

Open

Description

@rahicks26

Description

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

  1. Build an asp.net core application

  2. Configure trivial type provider that references the name of the connection string in appsettings.json

  3. 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.

Activity

  1. smoothdeveloper commented on Jan 27, 2020

    @smoothdeveloper
    Collaborator

    @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

    I'd be happy to review and merge such PR.

  2. rahicks26 commented on Jan 28, 2020

    @rahicks26
    Author

    @smoothdeveloper yeah that sounds fun. I will take a look this weekend and see what I can make of it.

  3. github-actions commented on Mar 14, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    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:
      {
        "ConnectionStrings": {
          "MyDb": "Server=.;Database=MyApp;Integrated Security=True"
        }
      }
    • 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:

    1. Pass the connection string via the connection constructor parameter (injected from IConfiguration), or
    2. 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.

    Generated by Repo Assist · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f
    
  4. added a commit that references this issue on Mar 14, 2026
    617156d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions