Browse Source

Synchronization code

pull/32/head
sunkaixuan 2 years ago
parent
commit
fd347a1113
  1. 5
      Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs

5
Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs

@ -443,6 +443,11 @@ namespace SqlSugar
ChangeKey(entityInfo, tableName, item); ChangeKey(entityInfo, tableName, item);
} }
} }
if (entityColumns.Count(it => it.IsPrimarykey)==1&&dbColumns.Count(it => it.IsPrimarykey) ==0)
{
var addPk=entityColumns.First(it => it.IsPrimarykey);
this.Context.DbMaintenance.AddPrimaryKey(tableName, addPk.DbColumnName);
}
if (isMultiplePrimaryKey) if (isMultiplePrimaryKey)
{ {
var oldPkNames = dbColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList(); var oldPkNames = dbColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList();

Loading…
Cancel
Save