You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entity ClassDef with public bool IsActive { get; set; } property. I want this property to be true by default, so I have configuration like builder.Property(x => x.IsActive).HasColumnName("IsActive").HasDefaultValue(true);.
When IsActive equals FALSE, EF does not generate insert for this column (like in this issue - #6054). So database value is always TRUE.
Note, that this is correct only for this config builder.Property(x => x.IsActive).HasColumnName("IsActive").HasDefaultValue(true);. If HasDefaultValue(false), everything works fine.
Thank you!
The text was updated successfully, but these errors were encountered:
The workaround mentioned in #6054 (and #7089) is still the valid way to deal with this - make your boolean property nullable. #15182 will improve this by allowing you to specify a nullable backing field instead.
Note that EF Core emits a warning for non-boolean store-generated properties which explains this (#7163). #15070 also contains some more information on alternatives recently considered by the team.
Hello!
I have an entity
ClassDef
withpublic bool IsActive { get; set; }
property. I want this property to be true by default, so I have configuration likebuilder.Property(x => x.IsActive).HasColumnName("IsActive").HasDefaultValue(true);
.When IsActive equals FALSE, EF does not generate insert for this column (like in this issue - #6054). So database value is always TRUE.
Note, that this is correct only for this config
builder.Property(x => x.IsActive).HasColumnName("IsActive").HasDefaultValue(true);
. If HasDefaultValue(false), everything works fine.Thank you!
The text was updated successfully, but these errors were encountered: