Search code examples
entity-frameworkenumslookup-tablesdatabase-first

Enums and lookup tables in Entity Framwork Database first


I am using Entity Framework Database First approach, and I use enums for the lookup tables. In database, the "normal" tables have a reference to a lookup tables, example:

Pet table:

  • Id
  • Name
  • PetTypeId

PetType table:

  • Id
  • Name

When I do the mapping from EF I exclude the lookup tables. I'm using T4 templates to generate the enums from database lookup tables.

My question: Is a bad practice to exclude the lookup tables from my EF model??


Solution

  • Finally I decided to map the lookup tables to the EF model, and convert to enum the two properties, the FK property in Pet table (PetTypeId), and the PK property in PetType table (Id).