From 33fab0093ca360cd33cdff8c2a121f09dae8cd17 Mon Sep 17 00:00:00 2001 From: Anuraj Date: Thu, 13 Oct 2016 23:28:18 +0530 Subject: [PATCH] Database update fix EF Core - Migrations database update fixed. --- .../Migrations/MySQLHistoryRepository.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/MySql.Data.EntityFramework7/Migrations/MySQLHistoryRepository.cs b/Source/MySql.Data.EntityFramework7/Migrations/MySQLHistoryRepository.cs index fa89e1a..0fe95f6 100644 --- a/Source/MySql.Data.EntityFramework7/Migrations/MySQLHistoryRepository.cs +++ b/Source/MySql.Data.EntityFramework7/Migrations/MySQLHistoryRepository.cs @@ -53,10 +53,18 @@ class MySQLHistoryRepository : HistoryRepository protected override string ExistsSql { - get - { - throw new NotImplementedException(); - } + get + { + var builder = new StringBuilder(); + builder.Append("SELECT COUNT(*) FROM information_schema.tables WHERE "); + if (TableSchema != null) + { + builder.Append($"table_schema = '{SqlGenerationHelper.EscapeLiteral(TableSchema)}' AND"); + } + + builder.Append($"table_name='{SqlGenerationHelper.EscapeLiteral(TableName)}'"); + return builder.ToString(); + } } public override string GetBeginIfExistsScript(string migrationId) @@ -79,9 +87,6 @@ public override string GetEndIfScript() throw new NotImplementedException(); } - protected override bool InterpretExistsResult([NotNull] object value) - { - throw new NotImplementedException(); - } + protected override bool InterpretExistsResult([NotNull] object value) => (long)value != 0L; } }