Should I store Enum ID/values in the database or a C# enumeration?

后端 未结 4 776
感情败类
感情败类 2021-01-11 14:35

Say my database tables have columns like UserType, SalesType, etc.

Should I have database tables with UserTypeID, userTy

4条回答
  •  悲&欢浪女
    2021-01-11 15:04

    What's wrong with both? If value's are user-defined or changing, definitely enum will not be suitable.

    If values are strictly non-changing (such as gender), you can have them as enums for ease of reference in the application and also in the DB as separate table to enforce foreign keys and as a reference.

提交回复
热议问题