SqlServer CodeFirst default value bug

This commit is contained in:
sunkaixuna
2021-07-23 20:44:54 +08:00
parent 934136ee08
commit 4a70624682

View File

@@ -313,6 +313,21 @@ namespace SqlSugar
#endregion
#region Methods
public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
{
if (defaultValue == "''")
{
defaultValue = "";
}
var template = AddDefaultValueSql;
if (defaultValue != null && defaultValue.ToLower() == "getdate()")
{
template = template.Replace("'{2}'", "{2}");
}
string sql = string.Format(template, tableName, columnName, defaultValue);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
/// <summary>
///by current connection string