-
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
HasDefaultValue not working properly for bool values #21664
Comments
@ajcvickers I have the same issue. .Net 8 (?) introduced this bug into our project, while it was still working with .Net 6 :/ |
I don't see how #15182 applies to this. There, you were only talking about nullable fields. Sorry, but your link spamming did not help at all. |
I found out more: Since EF Core does not know, it does not overwrite the bool value (anymore). This breaking change was introduced with |
I'm having the same Issue with EF Core 8 |
Hi,
I am trying to seed some data on my Users table (not identity Users table), but the thing is that even that I provide
false
value for it,HasDefaultValue(true)
, it adds always as true on the database. When I removeHasDefaultValue()
it works perfectly, so the right value is being saved on the database. Otherwise its always true.Steps to reproduce
Here's my UserAccount.cs (i use this for seeding data):
Here's my User.cs entity:
Here are the users that I am trying to seed:
Here's my DbContext:
When I run
add-migration SeedUsers
here's what it being shown in `timestamp_SeedUsers.csWhile if I remove
.HasDefaultValue(true)
fromUser.IsActive
property in DbContext, then this is what i get intimestamp_SeedUsers.cs
Further technical details
EF Core version: 3.1.5
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows 10 Enterprise
IDE: Visual Studio 2019 16.4.3
The text was updated successfully, but these errors were encountered: