efcore
efcore copied to clipboard
Issue with Column Naming in Migrations for Snake Case
Package Version:
- Microsoft.EntityFrameworkCore Version 8.0.7
- Microsoft.EntityFrameworkCore.Design Version 8.0.7
- Microsoft.EntityFrameworkCore.Relational Version 8.0.7
- Microsoft.EntityFrameworkCore.Tools Version 8.0.7
- Npgsql.EntityFrameworkCore.PostgreSQL Version 8.0.4
Description I'm experiencing an issue when renaming columns in my migrations. Despite successfully renaming columns to snake_case, the migration process still attempts to insert values into the original camelCase column names.
Steps to Reproduce
Create a migration to rename a column in the migrations_history table from ProductVersion to product_version.
migrationBuilder.RenameColumn(
name: "ProductVersion",
schema: "universal_family",
table: "migrations_history",
newName: "product_version"
);
Run the migration using the command:
dotnet ef database update
Observe the following error in the logs:
Npgsql.PostgresException (0x80004005): 42703: column "ProductVersion" of relation "migrations_history" does not exist
The SQL statement being executed is:
INSERT INTO universal_family.migrations_history ("MigrationId", "ProductVersion") VALUES ('20241010144908_ChangeMigrationStyleNames', '8.0.7');
Expected Behavior I expect the migration process to utilize the updated column names, specifically using product_version instead of ProductVersion in SQL statements, like this:
INSERT INTO universal_family.migrations_history ("MigrationId", product_version) VALUES ('20241010144908_ChangeMigrationStyleNames', '8.0.7');
Actual Behavior The migration attempts to reference the old column names (ProductVersion), resulting in an error that indicates the column does not exist.
Additional Information
- This behavior occurs despite correctly renaming the columns in the migration.
- I have confirmed that the migration has been applied and that the database schema reflects these changes.
- There appears to be a discrepancy between the snapshot of the migrations and the actual state of the database, which leads to this issue.