SmartEnum icon indicating copy to clipboard operation
SmartEnum copied to clipboard

How to persist SmartFlagEnum in EF Core

Open zyofeng opened this issue 1 year ago • 3 comments

Currently im using the following syntax in CodeFirst but EF Core complains about AccountRoles not having a primary key (I assume this was due to the missing convertor)

Is there a guide on how to use SmartFlagEnum with EFCore?

public virtual ICollection<AccountRoles> Roles { get; internal set; } = new HashSet<AccountRoles>();

public sealed class AccountRoles : SmartFlagEnum<AccountRoles> { public static readonly AccountRoles Primary = new AccountRoles("Primary", 1 << 0); public static readonly AccountRoles Secondary = new AccountRoles("Secondary", 1 << 1); }

zyofeng avatar Mar 13 '23 03:03 zyofeng