> I usually use C# Enums translated by EF Core now (...)
Does this approach ensure data consistency? Or could you accidentally insert a number value into your table which is not represented by any of the enum values?
Does this approach ensure data consistency? Or could you accidentally insert a number value into your table which is not represented by any of the enum values?
I “manually” add a check constraint (via EF, so it’s not so much manual as it is “remember to copy and paste this in your db.cs) to assert the value is greater than or equal to zero and less than the number of inhabitants in the enum, but this fails if you manually code the enum values (eg for flags, legacy interop, etc).