diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs index caec5a8c3..3899fcc29 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs @@ -20,6 +20,7 @@ namespace SqlSugar columns.Add(dbColumnInfo); } } + columns = columns.OrderBy(it => it.IsPrimarykey ? 0 : 1).ToList(); this.Context.DbMaintenance.CreateTable(tableName, columns,true); } protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)