public static string GetDefaultText(this PropertyModel property) { switch (property.PropertyType) { case PropertyTypeConstants.AuditCreatedDate: return("DEFAULT (getdate())"); case PropertyTypeConstants.AuditModifiedDate: return("DEFAULT (getdate())"); case PropertyTypeConstants.AuditTimestamp: return(""); } var defaultText = string.Empty; if (property.DefaultValue != null) { if (property.DefaultValue?.StartsWith("**") == true) { var v = property.DefaultValue.Replace("**", string.Empty); if (property.IsDate() && v == EFCore.Extensions.Attributes.DefaultValueSpecialAttribute.DefaultValueTypeConstants.CurrentTime.ToString()) { defaultText = $"DEFAULT (GETDATE())"; } else if (property.IsDate() && v == EFCore.Extensions.Attributes.DefaultValueSpecialAttribute.DefaultValueTypeConstants.CurrentTimeUTC.ToString()) { defaultText = $"DEFAULT (GETUTCDATE())"; } else if (property.IsString() && v == EFCore.Extensions.Attributes.DefaultValueSpecialAttribute.DefaultValueTypeConstants.AppName.ToString()) { defaultText = $"DEFAULT (APP_NAME())"; } else if (property.IsString() && v == EFCore.Extensions.Attributes.DefaultValueSpecialAttribute.DefaultValueTypeConstants.DbUser.ToString()) { defaultText = $"DEFAULT (system_user)"; } else { throw new Exception("Unknown default"); } } else if (property.IsBoolean()) { defaultText = "DEFAULT (" + (property.DefaultValue?.ToLower() == "false" ? "0" : "1") + ")"; } else if (property.IsString()) { defaultText = $"DEFAULT ('{property.DefaultValue}')"; } else if (property.IsNumeric()) { defaultText = $"DEFAULT ({property.DefaultValue})"; } else { throw new Exception("Unknown default"); } } return(defaultText); }