ardalis / ardalis/SmartEnum

Recommended way to force varchar / unicode=false on SmartEnum properties with EFCore

Open
#375 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.4k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

I'd like to force the EFCore generated property types for all SmartEnums with a Value type of string to be varchars instead of the nvarchar (unicode) default. I know this is really more of an EFCore type question, but because of the generic nature of the enum types, I haven't been able to figure out quite what it would look like.

I would normally just turn off Unicode for the relevant type in ConfigureConventions():
````
configurationBuilder.Properties().AreUnicode(false);
````
I think I could just list each specific enum type like this:
````
cofigurationBuilder.Properties>().AreUnicode(false);
configurationBuilder.Properties>().AreUnicode(false);
````
But I was hoping to do something more generic based on inheritance/derived types and not have to hardcode each of them.

Anyone know of a way I could do that globally to all the types derived from SmartEnum?

Thanks-

Contributor guide

Open the contributing guide

Research direction

No repository files or tests are named. Start by examining EF Core ConfigureConventions and how SmartEnum derived types are represented, then determine whether a global varchar configuration is possible for string-valued SmartEnums. Done should be a confirmed recommendation or a clearly scoped supported change, with relevant documentation or tests identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.