I have a table, lets call it Objects. It has a predefined set of records looking like this:
ObjectId ObjectName
1 Salmon
2 Trout
3 Seabass
4 Shark
Etc..
So, this I would like to implement somehow as an enum. But what’s the best way, implement it in the database creating tables for it or in the application logic in an CommonEnums codebehind file etc?
We add them in both places, we use code generator to keep in sync the values.
The main values are in the Enum but the template automatically generates a script to update the DB
We also add a property to our entities to expose an enum property instead of the integer that is saved to the DB
Edit: Adding an example of how to do it (In VB.NET:
Later an EnumHelper class take the classes that has the attribute EnumDbTableInfo and generates the script to update the DB
Best Regards