You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow applications to force nullability of columns #24685
By default, a column is nullable in the database if the property to which it is mapped is nullable. This is true even if the converter itself never converts nulls, since by default nulls are passed through unconverted. However, if the value converter converts nulls and ensures that no null values result from this conversion, then it it can make sense for the database column to be non-nullable.
Reacted by trevorgray, Shirleen Loh, MisinformedDNA, macias, Grace Whitney and Playwo
Add SetIsNullable(this IMutableProperty, bool, in StoreObjectIdentifier) to allow configuring column nullability independently from property nullability.
@ajcvickers I have the exact same issue as in [#27227] (#27227) and have tried to use this as the solution but no joy.
I have an entity, MyEntity with a property defined as follows:
NullableTime NonNullableButNullInDB { get; set; }
NullableTime is a special type class which expects to be always populated in the model but may have a null DateTime associated with it in the DB. The existence and usage of this class is legacy and I can't get rid of it at the moment so have to be able to support it.
The property 'MyEntity.NonNullableButNullInDB' cannot be marked as nullable/optional because the type of the property is 'NullableTime' which is not a nullable type. Any property can be marked as non-nullable/required, but only properties of nullable types can be marked as nullable/optional.
at
at Microsoft.EntityFrameworkCore.Metadata.Internal.Property.SetIsNullable(Nullable`1 nullable, ConfigurationSource configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Property.set_IsNullable(Boolean value)
at MyEntityConfiguration.ConfigureMappings(EntityTypeBuilder`1 entity)
Should I expect this to work now or has the support for this been reverted?
changed the title [-]Allow value converters to change nullability of columns[/-][+]Allow applications to force nullability of columns[/+]on Oct 25, 2022
Activity
ajcvickers commentedon Oct 21, 2021
Note from triage: Ping @AndriySvyryd when working on this.
AndriySvyryd commentedon Oct 21, 2021
Add
SetIsNullable(this IMutableProperty, bool, in StoreObjectIdentifier)to allow configuring column nullability independently from property nullability.nettashamir-allocate commentedon Feb 9, 2022
@ajcvickers I have the exact same issue as in [#27227] (#27227) and have tried to use this as the solution but no joy.
I have an entity, MyEntity with a property defined as follows:
NullableTimeis a special type class which expects to be always populated in the model but may have a null DateTime associated with it in the DB. The existence and usage of this class is legacy and I can't get rid of it at the moment so have to be able to support it.In ConfigureMappings, I am setting
but I get the following exception:
at
Should I expect this to work now or has the support for this been reverted?
11 remaining items
ajcvickers commentedon Oct 25, 2022
Note from triage: Implement this through #27970.
[-]Allow value converters to change nullability of columns[/-][+]Allow applications to force nullability of columns[/+]