Skip to content

Commit

Permalink
Merge pull request #621 from WildGums/feature/automatically-asign-pro…
Browse files Browse the repository at this point in the history
…vider

asing provider by connection string
  • Loading branch information
ceo1647 authored Nov 10, 2023
2 parents bd8e9db + 592f645 commit a764689
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,25 @@ private void SetInitialState()
}

var allKnownProviders = Database.DbProvider.GetRegisteredProviders().Select(x => x.Value.Info).ToArray();
if (allKnownProviders.Length == 1)
foreach (var provider in allKnownProviders)
{
DbProvider = allKnownProviders.Single();
var connectionString = provider.CreateConnectionString(_initialConnectionString);
if (connectionString is null)
{
continue;
}

try
{
using var testConnection = provider.GetProvider().CreateConnection(connectionString.ToString());
}
catch
{
continue;
}

DbProvider = provider;
ConnectionString = connectionString;
}
}

Expand Down

0 comments on commit a764689

Please sign in to comment.