/// <inheritdoc/> protected override void ProcessPropertyAdded( IConventionPropertyBuilder propertyBuilder, DefaultValueSqlAttribute attribute, MemberInfo clrMember, IConventionContext context) { if (propertyBuilder.CanSetDefaultValueSql(attribute.Value, true)) { propertyBuilder.HasDefaultValueSql(attribute.Value, true); } }
/// <summary> /// Configures the default value expression 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="sql"> The SQL expression for 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 HasDefaultValueSql( [NotNull] this IConventionPropertyBuilder propertyBuilder, [CanBeNull] string sql, bool fromDataAnnotation = false) { if (!propertyBuilder.CanSetDefaultValueSql(sql, fromDataAnnotation)) { return(null); } propertyBuilder.Metadata.SetDefaultValueSql(sql, fromDataAnnotation); return(propertyBuilder); }