using GetConnectionString() method with ConfigurationBuilder in asp.netcore5 webapi project

 

    public static string GetConnectionString()
        {
            IConfigurationRoot configuration = new ConfigurationBuilder()
                            .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                            .AddJsonFile("appsettings.json")
                            .Build();
            return configuration.GetConnectionString("DBConnection");
        }

Yorumlar