Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KennethScott opened this issue Feb 23, 2023 · 0 comments

Comments

@KennethScott
Copy link

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<string>().AreUnicode(false);

I think I could just list each specific enum type like this:

cofigurationBuilder.Properties<SmartEnum<MyConcreteType1, string>>().AreUnicode(false);
configurationBuilder.Properties<SmartEnum<MyConcreteType2, string>>().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-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant