0x80004005
dotnet
data_error
ai_generated
true
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite错误1:'没有这样的列:x'
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such column: x'
ID: dotnet/ef-core-sqlite-no-net-changes
85%修复率
85%置信度
1证据数
2023-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| EF Core 6.0 | active | — | — | — |
| EF Core 7.0 | active | — | — | — |
| EF Core 8.0 | active | — | — | — |
| SQLite 3.x | active | — | — | — |
根因分析
Entity Framework Core迁移未应用到SQLite数据库,实际架构与模型预期不匹配,导致查询引用了不存在的列。
English
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.
官方文档
https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli解决方案
-
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.
无效尝试
常见但无效的做法:
-
Adding a new migration and updating the database without reconciling the migration history
30% 失败
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% 失败
This loses all data and the migration history, but the error persists if the schema is not recreated via migrations.