Bug #71673 DropProcedureOperation and AlterProcedureOperation are not implemented
Submitted: 11 Feb 2014 20:58 Modified: 29 Sep 22:47
Reporter: Gabriel Bartolazzi Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.8.3 OS:Any
Assigned to: Jose Ramirez Ruiz CPU Architecture:Any

[11 Feb 2014 20:58] Gabriel Bartolazzi
Description:
DropProcedureOperation and AlterProcedureOperation are not implemented in MySqlMigrationSqlGenerator.
When MapToStoredProcedures is used and you want to make an upgrade can throw an exception.

How to repeat:
1- Create a simple context and generate the database using Enable-Migrations.

2- Modify the file Migrations/Configuration.cs
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

3- Add MapToStoredProcedures to an entity
For example:
 protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
   base.OnModelCreating(modelBuilder);
   modelBuilder.Entity<Car>().MapToStoredProcedures();
  }

4- Execute Update-Database
5- Add a new property to the entity.
6- Execute Update-Database again

Suggested fix:
Add DropProcedureOperation and AlterProcedureOperation in MySqlMigrationSqlGenerator.

#if EF6
      _dispatcher.Add("HistoryOperation", (OpDispatcher)((op) => { return Generate(op as HistoryOperation); }));
      _dispatcher.Add("CreateProcedureOperation", (OpDispatcher)((op) => { return Generate(op as CreateProcedureOperation); }));
      _dispatcher.Add("UpdateDatabaseOperation", (OpDispatcher)((op) => { return Generate(op as UpdateDatabaseOperation); }));
#endif
[29 Sep 22:47] Jose Ramirez Ruiz
Verified as valid against the current Connector/NET source.

MySqlMigrationSqlGenerator registers a handler for CreateProcedureOperation, but does not register handlers for either AlterProcedureOperation or DropProcedureOperation.

When EF6 migrations produces either operation—for example, after changing or removing an entity mapping created with MapToStoredProcedures()—the generator reaches its generic dispatch logic and throws:

System.NotImplementedException: AlterProcedureOperation
or:
System.NotImplementedException: DropProcedureOperation

This happens during SQL generation, before any SQL is sent to MySQL. The issue therefore remains reproducible with EF6 migrations and is valid. A fix should add generation and dispatch support for both operations, using MySQL-compatible DROP PROCEDURE IF EXISTS and an appropriate alter/recreate strategy.

Thank you for your bug report,
MySQL Team