【问题标题】:EFCore scaffoldEFCore 脚手架
【发布时间】:2018-11-22 00:01:48
【问题描述】:

我正在尝试使用脚手架创建模型:

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

这个数据库的图表:

https://i.stack.imgur.com/TV7EB.png

【问题讨论】:

标签: entity-framework scaffold


【解决方案1】:

试试这个命令:

Scaffold-DbContext "Filename=mydatabase.sqlite3" Microsoft.EntityFrameworkCore.Sqlite -OutputDir 模型

我从 EF Core 的第一个版本到新的 2.1 都使用它,它对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-03
    • 2014-08-14
    • 1970-01-01
    • 2014-10-01
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多