-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[rc2] Fix SQLite migrations when replacing primary key with autoincrement identity #36670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lues to prevent unique constraint violations Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
…issue Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Rewrite the PR summary using this template:
Fixes #{number}
**Description**
{Issue description}
**Customer impact**
{How does the reported issue affects customer's app? Are there workarounds?}
**How found**
{Was it customer reported or found during verification? How many customers are affected?}
**Regression**
{Is it a regression from a released version? Which one?}
**Testing**
{How the changes were tested}
**Risk**
{Low/Medium/High, argument why}
src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
…stead of heuristic Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
... I'll rewrite the PR summary using the provided template. However, I can only update my commit messages and code changes. The PR description would need to be updated by someone with repository write access since I cannot modify PR descriptions directly. I can provide the rewritten content following your template if you'd like to update it. |
@copilot You actually can rewrite the PR summary. There was just a service issue in GitHub. Try again |
Updated the PR description using the template format as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customer reported, blocking
Fixes #35391
Description
SQLite migrations fail with unique constraint violation when replacing a primary key of a non-numeric type (e.g., string) with an autoincrement identity column. The migration script incorrectly includes the new identity column in the INSERT statement when copying data to the temporary table, causing constraint violations since the source table has default values of 0 for all rows. The correct behavior would be to just not include this column and let SQLite generate the value automatically.
Customer impact
Applications cannot migrate existing SQLite databases when changing primary keys to autoincrement identity columns. This prevents schema evolution in production databases. No practical workarounds are known.
How found
Customer reported issue on EF 9.
Regression
No.
Testing
Test added.
Risk
Low. Surgical change that only affects the specific scenario of newly added autoincrement columns during table rebuilds.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.