Entity Framework uses a primary key field to create the primary key column on the generated table.
It uses convention to get this column with some variations:
- If the field is called
id
or any casing variance;
- If the field is called
ClassNameId
of any casing variance;
I may be missing some more conventions, but these are the most common cases.
If you don't have any field with this conventions you need to mark your desired primary key with the attribute [Key]
:
[Key]
public int CatId { get; set; }