Enums or Tables?

后端 未结 9 929
天命终不由人
天命终不由人 2021-02-06 08:38

I am making this a community wiki, as I would appreciate people\'s approach and not necessarily an answer.

I am in the situation where I have a lot of lookup type data

9条回答
  •  旧时难觅i
    2021-02-06 08:56

    Have a look at my suggestion here How to work with Enums in Entity Framework?

    Essentially I use default values sql scripts for core lookup data, with ID's for FK references from other tables, and then I use a simple T4 template to generate my enums for c#. That way the Database is efficient, normalised and correctly constrained, and my c# entities don't have to deal with ID's (Magic numbers).

    Its simple quick, easy, and does the job for me.

    I use EF4, but you don't need to, could use this approach with whatever technology you use for your entities.

提交回复
热议问题