Bug #70080 | Downgrade With Foreign Key Results In "Error on rename" error. | ||
---|---|---|---|
Submitted: | 19 Aug 2013 5:06 | Modified: | 20 Jan 2014 19:08 |
Reporter: | William Roush | Email Updates: | |
Status: | Unsupported | Impact on me: | |
Category: | Connector / NET | Severity: | S3 (Non-critical) |
Version: | 6.7.4.0 | OS: | Any |
Assigned to: | Francisco Alberto Tirado Zavala | CPU Architecture: | Any |
[19 Aug 2013 5:06]
William Roush
[19 Aug 2013 5:36]
William Roush
An example fix would be to sort your operations prior to calling base.Generate in MySqlMigrationCodeGenerator under ScaffoldedMigration Generate(...): You'll want to resort foreign keys to be LAST on the operations list, when generating the downgrade, the operations list gets reversed, this will make the foreign keys be the first things removed, which will prevent the error: PM> Add-Migration Install -Force Scaffolding migration '201308190527459_Install'. PM> Update-Database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Applying code-based migrations: [201308190527459_Install]. Applying code-based migration: 201308190527459_Install. Running Seed method. PM> Update-Database -T:0 Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Reverting migrations: [201308190527459_Install]. Reverting code-based migration: 201308190527459_Install. PM> Migration now works as expected.
[20 Jan 2014 19:08]
Francisco Alberto Tirado Zavala
The issue is in Entity Framework, and can be reproduced using EF5 and SQL Server too. But the issue is not present using EF6 and ConnectorNet 6.8.X