-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
130 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2022 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/ | ||
// Licensed under MIT license. See License.txt in the project root for license information. | ||
|
||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Scaffolding; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Sqlite.Scaffolding.Internal; | ||
using Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal; | ||
|
||
namespace EfSchemaCompare.Internal; | ||
|
||
internal static class DatabaseModelFinder | ||
{ | ||
private const string SqlServerProviderName = "Microsoft.EntityFrameworkCore.SqlServer"; | ||
private const string SqliteProviderName = "Microsoft.EntityFrameworkCore.Sqlite"; | ||
private const string PostgresSqlProviderName = "Npgsql.EntityFrameworkCore.PostgreSQL"; | ||
|
||
public static IDatabaseModelFactory GetDatabaseModelFactory(this DbContext context) | ||
{ | ||
|
||
var providerName = context.Database.ProviderName; | ||
|
||
var logger = context.GetService<IDiagnosticsLogger<DbLoggerCategory.Scaffolding>>(); | ||
|
||
if (providerName == SqlServerProviderName) | ||
return new SqlServerDatabaseModelFactory(logger); | ||
if (providerName == SqliteProviderName) | ||
{ | ||
var typeMapper = context.GetService<IRelationalTypeMappingSource>(); | ||
return new SqliteDatabaseModelFactory(logger, typeMapper); | ||
} | ||
if (providerName == PostgresSqlProviderName) | ||
return new NpgsqlDatabaseModelFactory(logger); | ||
|
||
throw new InvalidOperationException("Your database provider isn't supported by the EfCore.SchemaCompare library. " + | ||
"Please provide an issue about the database type you would like and I may be able to add it."); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.