From 25420a7163eca41fca4d2f4b7c018660f2b0393c Mon Sep 17 00:00:00 2001 From: hughs lee <546682631@qq.com> Date: Fri, 19 Aug 2022 10:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A2=E5=BC=95=E5=90=8D=E6=94=AF=E6=8C=81{t?= =?UTF-8?q?able}=E5=8D=A0=E4=BD=8D=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=A1=AB?= =?UTF-8?q?=E5=85=85=E5=BD=93=E5=89=8D=E8=A1=A8=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CodeFirstProvider/CodeFirstProvider.cs | 14 +++++++++++--- .../CodeFirstProvider/CodeFirstProvider.cs | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs index 12087f81a..471e574a2 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs @@ -234,10 +234,18 @@ namespace SqlSugar { item.IndexName = (this.Context.CurrentConnectionConfig.IndexSuffix+ item.IndexName); } - var database = "{db}"; - if (item.IndexName!=null&&item.IndexName.Contains(database)) + if (item.IndexName != null) { - item.IndexName = item.IndexName.Replace(database, this.Context.Ado.Connection.Database); + var database = "{db}"; + if (item.IndexName.Contains(database)) + { + item.IndexName = item.IndexName.Replace(database, this.Context.Ado.Connection.Database); + } + var table = "{table}"; + if (item.IndexName.Contains(table)) + { + item.IndexName = item.IndexName.Replace(table, entityInfo.DbTableName); + } } if (!this.Context.DbMaintenance.IsAnyIndex(item.IndexName)) { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs index 12087f81a..471e574a2 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs @@ -234,10 +234,18 @@ namespace SqlSugar { item.IndexName = (this.Context.CurrentConnectionConfig.IndexSuffix+ item.IndexName); } - var database = "{db}"; - if (item.IndexName!=null&&item.IndexName.Contains(database)) + if (item.IndexName != null) { - item.IndexName = item.IndexName.Replace(database, this.Context.Ado.Connection.Database); + var database = "{db}"; + if (item.IndexName.Contains(database)) + { + item.IndexName = item.IndexName.Replace(database, this.Context.Ado.Connection.Database); + } + var table = "{table}"; + if (item.IndexName.Contains(table)) + { + item.IndexName = item.IndexName.Replace(table, entityInfo.DbTableName); + } } if (!this.Context.DbMaintenance.IsAnyIndex(item.IndexName)) {