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

Enum value entity framework considers the default value is 0 #30661

Closed
safaairaq100 opened this issue Apr 11, 2023 · 1 comment
Closed

Enum value entity framework considers the default value is 0 #30661

safaairaq100 opened this issue Apr 11, 2023 · 1 comment

Comments

@safaairaq100
Copy link

hello,
If I set the value in model LeftThumb (0) the value is saved in the database RightIndexFinger (6) because the entity framework considers the default value is 0 so the value will be RightIndexFinger (6) in (.HasDefaultValue(Fingers.RightIndexFinger)).
The issue was solved by setting LeftThumb=1 but is this issue or its normal behavior?
EntityFramework6 c# .netcore

` public enum Fingers
{
    LeftThumb,
    LeftIndexFinger,
    LeftMiddle,
    LeftRingFinger,
    LeftPinky,
    RightThumb,
    RightIndexFinger,
    RightMiddle,
    RightRingFinger,
    RightPinky
}
public class EmployeeFingerPrint
{
    public Guid EmployeeFingerPrintGuid { set; get; }
    public Guid EmployeeGuid { set; get; }
    public Fingers FingerNumber { set; get; }
}

public class EmployeeFingerPrintConfiguration : IEntityTypeConfiguration<EmployeeFingerPrint>
{
    public void Configure(EntityTypeBuilder<EmployeeFingerPrint> builder)
    {
        builder.ToTable("EmployeeFingerPrint").HasKey(k => k.EmployeeFingerPrintGuid);

        builder.Property(p => p.FingerNumber).HasColumnType("tinyint")
            .HasDefaultValue(Fingers.RightIndexFinger).IsRequired();
   }
}`
@ajcvickers
Copy link
Contributor

Covered by #701 and other related issues.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants