diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs index 7cc138ac..4d83a783 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs @@ -9,6 +9,7 @@ using SqlSugar; using Volo.Abp.Data; using Volo.Abp.Domain; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; using Yi.Framework.SqlSugarCore.Abstractions; using Yi.Framework.SqlSugarCore.Repositories; using Yi.Framework.SqlSugarCore.Uow; @@ -24,7 +25,32 @@ namespace Yi.Framework.SqlSugarCore var configuration = service.GetConfiguration(); var section = configuration.GetSection("DbConnOptions"); Configure(section); + var dbConnOptions = new DbConnOptions(); + section.Bind(dbConnOptions); + //很多人遗漏了这一点,不同的数据库,对于主键的使用规约不一样,需要根据数据库进行判断 + SequentialGuidType guidType; + switch (dbConnOptions.DbType) + { + case DbType.MySql: + case DbType.PostgreSQL: + guidType= SequentialGuidType.SequentialAsString; + break; + case DbType.SqlServer: + guidType = SequentialGuidType.SequentialAtEnd; + break; + case DbType.Oracle: + guidType = SequentialGuidType.SequentialAsBinary; + break; + default: + guidType = SequentialGuidType.SequentialAtEnd; + break; + } + Configure(options => + { + options.DefaultSequentialGuidType = guidType; + }); + service.TryAddScoped(); //不开放sqlsugarClient