-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
I'm in the process of updating a large app from efcore 1.1 to efcore 2preview
Got everything working with the existing models and previous migrations but ran into this problem when adding new properties to the model.
I added a few properties to my model and then wanted to generate a migration. The new props are added like this:
entity.Property(p => p.PwdRequireNonAlpha)
.IsRequired()
.HasColumnType("bit")
.HasDefaultValue(true)
;
entity.Property(p => p.PwdRequireLowercase)
.IsRequired()
.HasColumnType("bit")
.HasDefaultValue(true)
;
entity.Property(p => p.PwdRequireUppercase)
.IsRequired()
.HasColumnType("bit")
.HasDefaultValue(true)
;
entity.Property(p => p.PwdRequireDigit)
.IsRequired()
.HasColumnType("bit")
.HasDefaultValue(true)
;
Then when I generated the migration I got a lot of warnings about default values for existing bool properties and also about my new ones like this:
The 'bool' property 'PwdRequireNonAlpha' on entity type 'SiteSettings' is configured with a
database-generated default. This default will always be used when the property has the value 'false',
since this is the CLR default for the 'bool' type. Consider using the nullable 'bool?' type instead so that
the default will only be used when the property value is 'null'.
So that means if later I update the value to false on the entity it will be changed to true?
I don't want a nullable bool, what I want is to add the column and for existing rows make it true.
How can I accomplish that?
alarimer, PaulRReynolds, ryanelian, wdmeest, virshu and 4 moreAhmedSuror