I like working with enums, but I found I haven’t used them much lately because I was fuzzy on how to use them in conjunction with Entity Framework. I’ve finally taken the time to get an example working in one of my personal projects, but because I’m feeling lazy today, I’m just going to link the StackOverflow that helped me. Eventually I’ll update this post with my own instructions and sample code. For now:

StackOverflow: How to create a table corresponding to enum in EF Core Code First?

Note: If you are using any of the built-in Identity stuff, overriding OnModelCreating() may give you this error: The entity type 'Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin<string>' requires a key to be defined To fix that, you’ll need to add a call to the base function from within OnModelCreating():

protected override void OnModelCreating(ModelBuilder builder)
  // Your other code here

Updates to the enum string names are successfully applied to the database through migrations, although of course you’ll want to be careful changing the meaning of the values after they are already referenced by other entities.

To continue taking your enums to the next level, see my other post: C# Enum Display Names With Spaces and Special Characters