Fix SQLite ExecuteUpdate with navigation properties#38056
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates EF Core’s SQLite SQL generation for ExecuteUpdate to avoid emitting UPDATE ... AS alias, which SQLite doesn’t support, fixing failures when updates involve navigation predicates or TPT inheritance joins.
Changes:
- Override
SqliteQuerySqlGenerator.VisitUpdateto generate alias-freeUPDATEstatements and rewrite multi-table updates by lifting target-referencing join predicates intoWHERE. - Adjust SQL baselines across SQLite bulk update functional tests to reflect the new alias-free SQL output.
- Re-enable previously failing TPT ExecuteUpdate scenarios by asserting the new valid SQL rather than expecting
SqliteException.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs | Adds SQLite-specific UPDATE SQL generation to avoid target-table aliases and to rewrite joins/predicates for SQLite scoping rules. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs | Updates expected SQL baselines for many ExecuteUpdate scenarios to use non-aliased UPDATE targets and qualified table-name column references. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs | Updates expected SQL baselines for non-shared model bulk updates to match alias-free UPDATE target rendering. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPTInheritanceBulkUpdatesSqliteTest.cs | Converts previously failing TPT ExecuteUpdate tests from expecting exceptions to asserting the new valid SQL. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPTFiltersInheritanceBulkUpdatesSqliteTest.cs | Same as above, but for filtered TPT scenarios; updates expected SQL accordingly. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPHInheritanceBulkUpdatesSqliteTest.cs | Updates TPH expected SQL baselines to remove UPDATE target aliases and qualify column references with the table name. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPHFiltersInheritanceBulkUpdatesSqliteTest.cs | Updates filtered TPH expected SQL baselines to the new alias-free UPDATE output. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPCInheritanceBulkUpdatesSqliteTest.cs | Updates TPC expected SQL baselines to remove UPDATE target aliases. |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/Inheritance/TPCFiltersInheritanceBulkUpdatesSqliteTest.cs | Updates filtered TPC expected SQL baselines to the new alias-free UPDATE output. |
b4dbd39 to
a2d7390
Compare
875d5a8 to
e038a97
Compare
AndriySvyryd
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38010
Fixes #31402
Problem
SQLite doesn't support referencing the UPDATE target table alias in JOIN ON clauses. When
ExecuteUpdateuses navigation properties in theWhereclause (or with TPT inheritance), EF Core generates SQL with JOINs that requires an alias on the UPDATE target table. This causesSqliteException: no such columnerrors.Solution
Override
VisitUpdateinSqliteQuerySqlGeneratorwith two strategies:Single-table updates (base path + VisitTable/VisitColumn overrides):
UPDATE "TableName"without aliasMulti-table updates (custom FROM rendering):
UPDATE "TableName"without aliasExample
Before (invalid SQLite):
After (valid SQLite):