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

When constraint for default value is set to true, C# model is generated as nullable #790

Closed
flamecrow opened this issue Feb 17, 2021 · 1 comment

Comments

@flamecrow
Copy link

flamecrow commented Feb 17, 2021

When a NOT NULL bit column has a constraint for default value set to TRUE (1), the C# model is generated as a nullable bool.

ALTER TABLE SomeTableName ADD CONSTRAINT DF_SomeTableName_SomeColumnName DEFAULT 1 FOR SomeColumnName

Produces:
public bool? SomeColumnName{ get; set; }

Expected:
public bool SomeColumnName{ get; set; }

If you set the default constraint to FALSE (0) it will produce the expected C# code.

Steps to reproduce

  1. Create a table
  2. Add bit column with NOT NULL and default value of TRUE
  3. Add bit column with NOT NULL and default value of FALSE
  4. Use EF Power Tools to reverse engineer models
  5. Observe the generated Null Conditional Operator in the column with default value of TRUE

Further technical details

EF Core Power Tools version: 2.5.454.0

Database engine: SQL Server

Visual Studio version: Visual Studio 2019, version 16.8.4

@ErikEJ
Copy link
Owner

ErikEJ commented Feb 17, 2021

Duplicate of #160 which was recently "fixed" with a new advanced option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants