mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
Update sqlite
This commit is contained in:
@@ -91,7 +91,7 @@ namespace SqlSugar
|
||||
{
|
||||
var tableName = GetTableName(entityInfo);
|
||||
string backupName=tableName+DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1");
|
||||
//Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1");
|
||||
List<DbColumnInfo> columns = new List<DbColumnInfo>();
|
||||
if (entityInfo.Columns.HasValue())
|
||||
{
|
||||
|
||||
@@ -358,10 +358,21 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
string sql = GetCreateTableSql(tableName, columns);
|
||||
if (!isCreatePrimaryKey)
|
||||
string primaryKeyInfo = null;
|
||||
|
||||
if (!isCreatePrimaryKey || columns.Count(it => it.IsPrimarykey) > 1)
|
||||
{
|
||||
sql = sql.Replace("PRIMARY KEY AUTOINCREMENT", "").Replace("PRIMARY KEY", "");
|
||||
}
|
||||
|
||||
if (columns.Count(it => it.IsPrimarykey) > 1 && isCreatePrimaryKey)
|
||||
{
|
||||
primaryKeyInfo = string.Format(",\r\n Primary key({0})", string.Join(",", columns.Where(it => it.IsPrimarykey).Select(it => this.SqlBuilder.GetTranslationColumnName(it.DbColumnName))));
|
||||
primaryKeyInfo = primaryKeyInfo.Replace("`", "\"");
|
||||
}
|
||||
|
||||
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
||||
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user