2

I am trying to create a Model, by using scaffold:

dotnet ef dbcontext scaffold "DataSource=database.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Model

But this return error:

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'.

I don't understund where error in my PoolInDepertaments table. Please, check my database: https://pastebin.com/Mmi6fnrV

And diagram for this DB:

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

Ruslan
  • 33
  • 5

1 Answers1

0

Try with this command:

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

I use this since the first versions of EF Core until the new 2.1 and it works for me.

Álvaro García
  • 18,114
  • 30
  • 102
  • 193