0

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??

Pedro Perez
  • 842
  • 6
  • 23
  • It's neither. If you need access to the lookup tables from one of your business services or a navigation property, it may just be missing. We do a lot of DB first here and I personally always include those tables along with creating an Enum using a T4 script – Steve Stokes May 29 '14 at 16:16
  • Thanks for your answer. I thought I was the only one that used database first. I have a doubt, I transform the property PetTypeId in Pet model to an enum, PetTypeId is now of type PetTypeEnum, not int. If I include the lookup table PetType in my EF model, PetTypeId (in Pet model) must to be of type int, because it references to a property of type int (Id in PetType). Also, I am not sure that I will need to use the navigation property of a lookup table. – Pedro Perez May 29 '14 at 20:18

1 Answers1

0

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

Pedro Perez
  • 842
  • 6
  • 23