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
bit not null created as bool? #160
Comments
Hmmm. That should have been fixed in 2.2 - can you please share a CREATE TABLE script, thanks |
Ping? |
Sorry for the delay have been travelling. /****** Object: Table [dbo].[Test] Script Date: 11-Jan-19 11:37:32 AM ******/ SET QUOTED_IDENTIFIER ON CREATE TABLE [dbo].[Test]( ALTER TABLE [dbo].[Test] ADD CONSTRAINT [DF_Test_TestBool] DEFAULT ((1)) FOR [TestBool] ` Test.cs namespace EFBitTest.Model efpt.config.json |
TestBool bit NOT NULL DEFAULT 1 This is by-design in EF Core. If the property wasn't nullable, there would be no way to store a
|
Note, if you remove the |
Closing as by design |
@rationalmonkey @mike-upshon @smatvienko @rcfearn @StefanFalz @roopeshkumar Fixed in latest daily build (two years in the making) 😄 |
@ErikEJ - Would you be willing to add "Remove default constraint from bool columns" as a cli option? |
To what CLI?? |
@ErikEJ |
Our specific use case for this flag comes into play with EF Migrations. When you add a bit column to a table with existing data, you need to provide a sql default. Every time we create a new migration, we run this tool to update our POCOs, but it keeps converting our columns to nullable booleans. |
The repository is not that tool, that tool is in the official EF Core repository. Suggest you post the request there, feel free to refer to this issue! |
Ah, apologies, I came from the EF Core repo, but didn't realized I had switched repos. |
No worries, be aware that this feature is available in EF Core Power Tools |
When a table has column with type bit not null EFCore PowerTools generates as bool? instead of bool
Steps to reproduce
Create table with bit not null column and reverse engineer
Further technical details
EF Core Power Tools version: 2.2.2.0
Database engine: SqlServer
Visual Studio version: Visual Studio Ent 2017 15.9.5
The text was updated successfully, but these errors were encountered: