Closed ahmadalli closed 3 years ago
@ahmadalli Thanks for reporting! The issue is connected to the fix of #678. For more information, take a look at the latest comment over there or at the PR with the fix for your issue here.
Once we have merged #1282, feel free to use the latest nightly build containing the fix.
Thanks :) I'm looking forward to it
I'm sorry that I'm reporting two problems in a single issue. I was trying to reproduce a problem but I faced another one which was stopping me to reproduce the main problem. So I'm going to explain both of them
Steps to reproduce
here's my example code
The issue
If you run the sample project I provided (it's runnable on docker-compose), you'll face this exception when
StartupHostedService
tries to runawait dbContext.Database.MigrateAsync(cancellationToken);
.Exception message:
this is the exception you get when you run the project
Stack trace:
I guess it's happening when ef is trying to run this part of the migration
https://github.com/ahmadalli/PomeloMysqlFKTest/blob/e432af74d8ad3ef0c964dc376a6a3698ea0993e4/FKTest/Migrations/20201227210928_ChangeIdColumn.cs#L17-L19
and it makes sense since
FK_Children_Parents_ParentId
has not been created yet, The migration should deleteFK_Children_Parents_ParentCode
instead.The Main Problem
I was facing another issue on my project and I wanted to report that (with similar section on migration code) but I faced this issue first. The issue I'm facing on another project is that the migration fails because it tries to run this query which obviously fails because there's no
ParentId
column inParents
table:I was looking for the code that generates this query but I couldn't find it but I found the code that's supposed to test it:
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/c8647fc801397185faa429878d361c949826cf26/test/EFCore.MySql.FunctionalTests/MigrationSqlGeneratorMySqlTest.MySql.cs#L49-L54
But I think these lines doesn't cover all the corner cases since it the
LicensePlateNumber
is the name of foreign key column and also the name of primary column on the reference table.Further technical details
MySQL version: 5.7 Operating system: Windows 10 Pomelo.EntityFrameworkCore.MySql version: 5.0.0-alpha.2 Microsoft.AspNetCore.App version: 5.0.1