mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update AddPrimaryKeys
This commit is contained in:
parent
9e7e1d197d
commit
f944d339e9
@ -10,9 +10,19 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
public static void CodeFirst()
|
public static void CodeFirst()
|
||||||
{
|
{
|
||||||
|
Db.CodeFirst.InitTables<UnitCodeFirstpks2>();
|
||||||
if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false))
|
if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false))
|
||||||
Db.DbMaintenance.DropTable("UnitCodeTest1");
|
Db.DbMaintenance.DropTable("UnitCodeTest1");
|
||||||
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
||||||
|
Db.CodeFirst.InitTables<UnitCodeFirstpks2>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnitCodeFirstpks2
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
|
||||||
|
public string id { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public string id2 { get; set; }
|
||||||
}
|
}
|
||||||
public class UnitCodeTest1
|
public class UnitCodeTest1
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
var columnName = string.Join(",", columnNames);
|
var columnName = string.Join(",", columnNames);
|
||||||
string sql = string.Format(this.AddPrimaryKeySql, tableName, string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(columnNames.First()), this.SqlBuilder.GetNoTranslationColumnName(columnNames.First())), columnName);
|
var pkName = string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(tableName), columnName.Replace(",","_"));
|
||||||
|
string sql = string.Format(this.AddPrimaryKeySql, tableName,pkName, columnName);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user