var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); //Create Connection using (var connection = new MySqlConnection { ConnectionString = configuration.GetConnectionString("ConnContext") }) { connection.Open(); //Prepare query string var cmd = new MySqlCommand("SELECT * FROM Connection;", connection); //Read data using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { var row = $"{rdr["ConnStr"]}\t\t{rdr["Remark"]}"; Console.WriteLine(row); } } connection.Close(); }