private (string connectionKey, ISqlConnections sqlConnections) SelectConnectionString(GeneratorConfig config, string csproj)
            {
                var projectDir = Path.GetDirectoryName(csproj);
                var connectionStringOptions = new ConnectionStringOptions();

                foreach (var x in config.Connections.Where(x => !x.ConnectionString.IsEmptyOrNull()))
                {
                    connectionStringOptions[x.Key] = new ConnectionStringEntry
                    {
                        ConnectionString = x.ConnectionString,
                        ProviderName     = x.ProviderName,
                        Dialect          = x.Dialect
                    };
                }

                foreach (var name in config.GetAppSettingsFiles())
                {
                    var path = Path.Combine(projectDir, name);
                    if (File.Exists(name))
                    {
                        var appSettings = JSON.ParseTolerant <AppSettingsFormat>(File.ReadAllText(path).TrimToNull() ?? "{}");
                        if (appSettings.Data != null)
                        {
                            foreach (var data in appSettings.Data)
                            {
                                // not so nice fix for relative paths, e.g. sqlite etc.
                                if (data.Value.ConnectionString.Contains("../../..", StringComparison.Ordinal))
                                {
                                    data.Value.ConnectionString = data.Value
                                                                  .ConnectionString.Replace("../../..", Path.GetDirectoryName(csproj), StringComparison.Ordinal);
                                }
                                else if (data.Value.ConnectionString.Contains(@"..\..\..\", StringComparison.Ordinal))
                                {
                                    data.Value.ConnectionString = data.Value.ConnectionString.Replace(@"..\..\..\",
                                                                                                      Path.GetDirectoryName(csproj), StringComparison.Ordinal);
                                }

                                connectionStringOptions[data.Key] = data.Value;
                            }
                        }
                    }
                }

                if (connectionStringOptions.Count == 0)
                {
                    AnsiConsole.Write(new Markup($"[bold red]No connections in appsettings files or sergen.json![/]"));
                    AnsiConsole.WriteLine();
                    return(null, null);
                }

                var connectionKeys = connectionStringOptions.Keys.OrderBy(x => x).ToArray();

                DbProviderFactories.RegisterFactory("Microsoft.Data.SqlClient",
                                                    Microsoft.Data.SqlClient.SqlClientFactory.Instance);
                DbProviderFactories.RegisterFactory("System.Data.SqlClient",
                                                    Microsoft.Data.SqlClient.SqlClientFactory.Instance);
                DbProviderFactories.RegisterFactory("Microsoft.Data.Sqlite",
                                                    Microsoft.Data.Sqlite.SqliteFactory.Instance);
                DbProviderFactories.RegisterFactory("Npgsql",
                                                    Npgsql.NpgsqlFactory.Instance);
                DbProviderFactories.RegisterFactory("FirebirdSql.Data.FirebirdClient",
                                                    FirebirdSql.Data.FirebirdClient.FirebirdClientFactory.Instance);
                DbProviderFactories.RegisterFactory("MySql.Data.MySqlClient",
                                                    MySqlConnector.MySqlConnectorFactory.Instance);

                var sqlConnections = new DefaultSqlConnections(
                    new DefaultConnectionStrings(connectionStringOptions));

                AnsiConsole.WriteLine();
                var selections = new SelectionPrompt <string>()
                                 .Title("[steelblue1]Available Connections[/]")
                                 .PageSize(10)
                                 .MoreChoicesText("[grey](Move up and down to reveal more connections)[/]")
                                 .AddChoices(connectionKeys);

                return(AnsiConsole.Prompt(selections), sqlConnections);
            }