I am using EF Core Power Tools
version 2.4.0
with Miccrosoft.EntifyFrameworkCore.SqlServer
version 2.2.6
I have SQL table column IsActive
defined as [IsActive] [bit] NOT NULL
I use EF Core Power Tool's reverse engineering to generate entities and DB Context.
ISSUE
The tool generate null-able Boolean property instead of just Boolean
public bool? IsActive { get; set; }
the corresponding DBContext's OnModelCreating method
modelBuilder.Entity<Scenario>(entity =>
{
entity.Property(e => e.ScenarioID).HasColumnName("ScenarioID");
entity.Property(e => e.IsActive)
.IsRequired()
.HasDefaultValueSql("((1))");
}
Without nullable, there would be no way to insert a 0!
you can insert0
in not null column – Deva