Fixing errors with in-memory context, adding integrity hash tag helper
This commit is contained in:
@@ -31,6 +31,9 @@ namespace Microsoft.EntityFrameworkCore
|
||||
var options = new DatabaseMigrationOptions();
|
||||
optionsAction?.Invoke(options);
|
||||
|
||||
if (database.GetProviderType() == DatabaseProvider.InMemory)
|
||||
return true;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(options.MigrationsTableName))
|
||||
throw new ArgumentNullException(nameof(options.MigrationsTableName), $"The property {nameof(options.MigrationsTableName)} of the {nameof(options)} parameter is required.");
|
||||
|
||||
@@ -41,6 +44,7 @@ namespace Microsoft.EntityFrameworkCore
|
||||
try
|
||||
{
|
||||
await connection.OpenAsync(cancellationToken);
|
||||
|
||||
if (!await connection.CreateMigrationsTable(options, cancellationToken))
|
||||
return false;
|
||||
|
||||
@@ -52,10 +56,14 @@ namespace Microsoft.EntityFrameworkCore
|
||||
}
|
||||
}
|
||||
|
||||
private static DatabaseProvider GetProviderType(this DbConnection connection)
|
||||
{
|
||||
string provider = connection.GetType().FullName;
|
||||
private static DatabaseProvider GetProviderType(this DatabaseFacade database)
|
||||
=> GetProviderType(database.ProviderName);
|
||||
|
||||
private static DatabaseProvider GetProviderType(this DbConnection connection)
|
||||
=> GetProviderType(connection.GetType().FullName);
|
||||
|
||||
private static DatabaseProvider GetProviderType(string provider)
|
||||
{
|
||||
if (provider.Contains("mysql", StringComparison.OrdinalIgnoreCase))
|
||||
return DatabaseProvider.MySQL;
|
||||
if (provider.Contains("oracle", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -74,9 +82,6 @@ namespace Microsoft.EntityFrameworkCore
|
||||
|
||||
private static async Task<bool> CreateMigrationsTable(this DbConnection connection, DatabaseMigrationOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
if (connection.GetProviderType() == DatabaseProvider.InMemory)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
using var command = connection.CreateCommand();
|
||||
@@ -140,9 +145,6 @@ END;"
|
||||
|
||||
private static async Task<bool> Migrate(this DbConnection connection, DatabaseMigrationOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
if (connection.GetProviderType() == DatabaseProvider.InMemory)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
List<string> availableMigrationFiles;
|
||||
|
||||
Reference in New Issue
Block a user