/// <inheritdoc/> protected override void ProcessPropertyAdded( IConventionPropertyBuilder propertyBuilder, DefaultValueAttribute attribute, MemberInfo clrMember, IConventionContext context) { if (propertyBuilder.CanSetDefaultValue(attribute.Value, true)) { propertyBuilder.HasDefaultValue(attribute.Value, true); } }
/// <summary> /// Configures the default value for the column that the property maps to when targeting a relational database. /// </summary> /// <param name="propertyBuilder"> The builder for the property being configured. </param> /// <param name="value"> The default value of the column. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> /// The same builder instance if the configuration was applied, /// <see langword="null" /> otherwise. /// </returns> public static IConventionPropertyBuilder HasDefaultValue( [NotNull] this IConventionPropertyBuilder propertyBuilder, [CanBeNull] object value, bool fromDataAnnotation = false) { if (!propertyBuilder.CanSetDefaultValue(value, fromDataAnnotation)) { return(null); } propertyBuilder.Metadata.SetDefaultValue(value, fromDataAnnotation); return(propertyBuilder); }