我正在尝试使用scaffold创建一个Model:
dotnet ef dbcontext scaffold "DataSource=database.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Model
但是这个返回错误:
Could not scaffold the foreign key 'PoolsInDepartments(pools_id)'. A key for 'id' was not found in the principal entity type 'Pools'.
Could not scaffold the foreign key 'PoolsInDepartments(departaments_id)'. A key for 'id' was not found in the principal entity type 'Departments'.
我不会在我的PoolInDepertaments表格中出现错误。请检查我的数据库: https://pastebin.com/Mmi6fnrV
此DB的图表:
答案 0 :(得分:0)
尝试使用此命令:
Scaffold-DbContext“ Filename = mydatabase.sqlite3” Microsoft.EntityFrameworkCore.Sqlite -OutputDir模型
自EF Core的第一个版本开始使用新版本2.1之前,我一直使用它。