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

EF Core does not include boolean column with default value in SQL INSERT statement #31538

Closed
Gurgen opened this issue Aug 23, 2023 · 2 comments
Closed

Comments

@Gurgen
Copy link

Gurgen commented Aug 23, 2023

When I set a boolean property with a default value in my entity and then try to add a new record with a value different from the default, EF Core generates an SQL INSERT statement without including that column.

Steps to reproduce:

  1. Create an entity with a boolean property.
  2. Configure the boolean property to have a default value of true.
  3. Add a new entity with the boolean property set to false.
  4. Notice that the generated SQL does not include the boolean column.

Expected behavior:
The SQL statement should include the boolean column with the value set to false.

Actual behavior:
The SQL statement does not include the boolean column, and the default value of true is always set.

EF Core version: 6.0.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6

@GertArnold
Copy link

See #7089. I've tried my best to explain why it's maddening. Apparently it's too deeply rooted in EF's logic based on CLR defaults to fix it.

@ajcvickers
Copy link
Contributor

Duplicate of #701

@ajcvickers ajcvickers marked this as a duplicate of #701 Sep 5, 2023
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 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

3 participants