Bug #116704 | MySql.EntityFrameworkCore 8.0.8 rename bug | ||
---|---|---|---|
Submitted: | 19 Nov 2024 7:46 | Modified: | 4 Jan 5:55 |
Reporter: | live tony | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 8,0 | OS: | Any |
Assigned to: | Omar Chavez | CPU Architecture: | Any |
Tags: | Entity Framework Core |
[19 Nov 2024 7:46]
live tony
[19 Nov 2024 9:19]
MySQL Verification Team
Hi Mr. tony, Thank you for your bug report. However, this is a forum for the reports with fully repeatable test cases. Hence, you have to provide entire model, with all details, and all instructions so that we can repeat the problem. You should also provide info on the versions and releases of all software that you used. We do hope that you are not using release 8.0.8, since that one is so longer supported. Can't repeat.
[20 Nov 2024 4:08]
live tony
According to the information on NuGet, version 8.0.8 is the latest stable release. I am writing to report a bug encountered in the MySql.EntityFrameworkCore package, version 8.0.8, which is causing a System.NullReferenceException when attempting to update the database schema using Entity Framework Core migrations. The issue arises specifically when executing a migration that includes a RenameColumn operation. Upon executing the dotnet ef database update command to apply migrations, the process fails when it attempts to execute a migration containing a RenameColumn operation. The error message provided is as follows: System.NullReferenceException: Object reference not set to an instance of an object. at MySql.EntityFrameworkCore.Migrations.MySQLMigrationsSqlGenerator.Generate(RenameColumnOperation operation, IModel model, MigrationCommandListBuilder builder) This exception suggests that there is a null reference being accessed within the MySQLMigrationsSqlGenerator.Generate method when processing the RenameColumnOperation. How to repeat: Create a new migration that includes renaming a column in a table using Entity Framework Core. Execute the dotnet ef migrations add [MigrationName] command to add the migration. Attempt to update the database using the dotnet ef database update command. Suggested fix: Upon reviewing the source code, I believe the issue may stem from improper null handling in the MySQLMigrationsSqlGenerator.Generate method. Specifically, changing the logical negation operator (!) to a null-conditional operator (?) at line 131 could address the null reference problem. This change would ensure that the operation is only attempted if the object in question is not null, thus avoiding the exception.
[20 Nov 2024 4:15]
live tony
This is a reproducible project, execute dotnet ef database update
Attachment: repeat_demo.zip (application/x-zip-compressed, text), 7.80 KiB.
[20 Nov 2024 4:28]
live tony
https://github.com/mysql/mysql-connector-net/blob/ac184e8a3626790551d381732b08680922882dd9...
[20 Nov 2024 4:33]
live tony
add tag
[20 Nov 2024 16:40]
Filipe Silva
Hi, Version 8.0.8 is correct. We just typically refer to it as 8.0.8+MySQL9.1.0, so that we make it clear we are referring to EFCore implementation for MySQL 9.1.0 and not MySQL 8.0.8. Thank you for all the details you provided. We'll analyze them and come back to you as soon as possible.
[21 Nov 2024 6:05]
live tony
Changing line 131 from var clrType = (converter!.ProviderClrType ?? typeMapping!.ClrType).UnwrapNullableType(); to var clrType = (converter?.ProviderClrType ?? typeMapping?.ClrType).UnwrapNullableType(); can fix this issue.
[22 Nov 2024 13:28]
MySQL Verification Team
HI Mr. Tony, Our team will analyse entire issue, but you will get the answer during next week.
[12 Dec 2024 4:09]
live tony
any updates?
[12 Dec 2024 11:00]
MySQL Verification Team
Hi Mr. tony, No, there are no news, except that a developer has been assigned to this bug report. We have contacted team in charge, so you will get some feedback.
[12 Dec 2024 16:11]
Omar Chavez
Hello, I tried to reproduce the error using the project provided but I couldn't do it. Can you provide a reproducible test project using a console application to get to this behaviour directly. Thanks.
[12 Dec 2024 16:29]
MySQL Verification Team
Hi Omar, We do agree with you. Without a reproducible test case we can not move forward.
[16 Dec 2024 6:06]
live tony
I have now uploaded a minimal reproducible example in the attachment named repeat_demo.zip. To reproduce the issue, please follow these steps: 1.Unzip the repeat_demo.zip file. 2.Navigate to the Models directory and update the connection string in the PrivDbContext.cs file to match your local MySQL setup. 3.Open a terminal or command prompt and change the directory to the root of the unzipped project. 4.Run the command "dotnet ef database update". This should allow you to encounter the bug as I have experienced it. I believe this will assist you in diagnosing the problem more effectively. Thank you for your attention to this matter, and I look forward to your response.
[16 Dec 2024 9:40]
live tony
console_application
Attachment: console_application.zip (application/x-zip-compressed, text), 15.41 MiB.
[16 Dec 2024 9:58]
live tony
console_application1.zip
Attachment: console_application1.zip (application/x-zip-compressed, text), 31.06 MiB.
[16 Dec 2024 9:59]
live tony
console_application1.zip
Attachment: console_application1.zip (application/x-zip-compressed, text), 31.06 MiB.
[16 Dec 2024 9:59]
live tony
I have created a console application to help reproduce the issue. Please follow these steps to replicate the problem: 1.Download and extract the contents of console_application1.zip. 2.Open the appsettings.json file and update the connection string in the appsettings.json file to match your local MySQL setup. 3.Run the program. This should set up the necessary environment to observe the behavior I reported
[16 Dec 2024 10:47]
MySQL Verification Team
Thank you, Mr. tony, Our Connector's team will take a look at your test case. Just let us know whether you have tried some newer C/NET release of 8.0 ???
[18 Dec 2024 2:37]
live tony
The submitted console_application1.zip is the latest version of .net 8.0.I have attempted to use the latest version of .NET 8.0, but unfortunately, I am still encountering the same issue.
[18 Dec 2024 10:42]
MySQL Verification Team
Thank for your feedback. Our C/Net team will take a look at it ......
[20 Dec 2024 16:47]
Omar Chavez
Verified using the test case provided
[20 Dec 2024 16:58]
MySQL Verification Team
Thank you, Omar.
[4 Jan 5:55]
live tony
any progress or updates regarding its fix?
[9 Jan 10:55]
MySQL Verification Team
Hi Mr. Tony, This bug is now verified. Hence, our team in charge will schedule it in the next couple of months.