Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Database First EF skip mapping some tables?

I'm using Entity Framework 4 and with a Database First binding, and EF is not generating the entities for a few of my tables. I'm not getting any errors, and no matter how many times I select the tables to generate from the "Update Model from Database" popup menu on the design surface, the same tables are still missing from the model.

I get no errors in the wizard. They just don't get generated. Any clues?

like image 566
John Kaster Avatar asked Dec 16 '22 13:12

John Kaster


2 Answers

EF requires a primary key on the table. EF will not map tables for which it can't find or derive a primary key. If all columns are nullable, it can't assume a primary key. If one or more columns are not nullable, EF will evidently derive a primary key for the table.

like image 143
John Kaster Avatar answered Jan 01 '23 16:01

John Kaster


EF will ignore table without primary keys.

like image 31
Akash Kava Avatar answered Jan 01 '23 14:01

Akash Kava