0x80004005
dotnet
data_error
ai_generated
true
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such column: x'
ID: dotnet/ef-core-sqlite-no-net-changes
85%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| EF Core 6.0 | active | — | — | — |
| EF Core 7.0 | active | — | — | — |
| EF Core 8.0 | active | — | — | — |
| SQLite 3.x | active | — | — | — |
Root Cause
Entity Framework Core migrations are not applied to the SQLite database, so the actual schema does not match the model expectations, causing queries to reference non-existent columns.
generic中文
Entity Framework Core迁移未应用到SQLite数据库,实际架构与模型预期不匹配,导致查询引用了不存在的列。
Official Documentation
https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cliWorkarounds
-
85% success Run 'dotnet ef database update' from the project directory to apply all pending migrations to the SQLite database.
Run 'dotnet ef database update' from the project directory to apply all pending migrations to the SQLite database.
-
90% success If migrations are missing, create an initial migration: 'dotnet ef migrations add InitialCreate' then run update.
If migrations are missing, create an initial migration: 'dotnet ef migrations add InitialCreate' then run update.
中文步骤
Run 'dotnet ef database update' from the project directory to apply all pending migrations to the SQLite database.
If migrations are missing, create an initial migration: 'dotnet ef migrations add InitialCreate' then run update.
Dead Ends
Common approaches that don't work:
-
Adding a new migration and updating the database without reconciling the migration history
30% fail
The migration history table in SQLite may be out of sync, causing EF to skip pending migrations.
-
Deleting the database file and recreating it manually
50% fail
This loses all data and the migration history, but the error persists if the schema is not recreated via migrations.