Skip to content

IConfiguration' does not contain a definition for 'GetSection' and no accessible extension method 'GetSection #1

Description

@mukaz4god

.Nte 3.0

public static void Main(string[] args)
{
Console.Title = "IdentityServer4";

        var host = CreateWebHostBuilder(args).Build();

        var config = host.Services.GetRequiredService<IConfiguration>();
        bool seed = config.GetSection("Data").GetValue<bool>("Seed");
        if (seed)
        {
            var connectionString = config.GetConnectionString("conn");
            Users.EnsureSeedData(connectionString);
        }

        host.Run();
    }

Severity Code Description Project File Line Suppression State
Error CS1061 'IConfiguration' does not contain a definition for 'GetSection' and no accessible extension method 'GetSection' accepting a first argument of type 'IConfiguration' could be found (are you missing a using directive or an assembly reference?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions