Bug #89218 EntityFramework Core __EFMigrationsHistoryTable Creation Condition Reversed
Submitted: 12 Jan 2018 22:26 Modified: 20 Apr 2018 6:17
Reporter: Richard Collette Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.10.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: entityframework

[12 Jan 2018 22:26] Richard Collette
Description:
An initial migration has and IF EXIST rather than an IF NOT EXIST when checking to see if the __EFMigrationsHistory table needs to be created.

The generated script is

IF EXISTS(SELECT 1 FROM information_schema.tables
  WHERE table_name = '
__EFMigrationsHistory' AND table_schema = DATABASE())
BEGIN
CREATE TABLE `__EFMigrationsHistory` (
    `MigrationId` varchar(150) NOT NULL,
    `ProductVersion` varchar(32) NOT NULL,
    PRIMARY KEY (`MigrationId`)
);

END;

How to repeat:
Create an InitialMigration in an entity framework core project like:

dotnet ef migrations add InitialMigration

Create the migration script using:

dotnet ef migrations script

Suggested fix:
Change the IF EXISTS to IF NOT EXISTS
[20 Apr 2018 6:17] Chiranjeevi Battula
Hello Richard Collette,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.