A workaround for storing enum values as strings in Entity Framework (classic) instead of their numeric equivalents. The approach uses a mapped string property (GenderString) with a private setter and a [NotMapped] attribute on the actual enum property, plus a generic ParseEnum extension method to convert the string back to the enum on load. The author acknowledges this is a hacky solution and notes a cleaner approach exists in Entity Framework Core.

2m read timeFrom nodogmablog.bryanhogan.net
Post cover image