-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Migrations: Convert enum values to underlying type #4061
Comments
This is a bug. We shouldn't be referencing the enum value at all here--it may change over time. Instead we should use the |
@bricelam public enum MyEnum
{
MyEnumItem = 'A'
} |
To get technical, it will be the underlying type of the enum which, in .NET can be byte, sbyte, short, ushort, int, uint, long, or ulong. In your example, the character literal specified is implicitly converted to int--the underlying type of MyEnum--during compilation. |
Marking for re-triage. #4353 perpetuates this issue into the model snapshot. |
@smitpatel we had another issue where we decided to just convert default values to the underlying type (rather than storing as the enum value)... so that work should resolve this one too. |
The other issue (#4286) was not allowing user to set default value for enums. While fixing it, we removed serialization introduced (which was causing the types to be from a fixed list) and converted it to enum value. Since Migrations also have same issue that user-defined enum is used instead of underlying value (this issue), we decided to fix it in model snapshot together. |
So does that mean this one was fixed as part of the other change? |
The other one is partially fixed. It allows users to set default values now but it introduce this issue in model snapshot. Since migrations is already facing this issue, model snapshot & migrations can both be fixed together. |
When creating a migration to add an
enum
column, the namespace of the enum is not included in the resulting migration.EG:
This results in
DNX,Version=v4.5.1 error CS0103: The name 'CommandStatus' does not exist in the current context
when runningdnx ef database update
The text was updated successfully, but these errors were encountered: