diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 46e6298f4..7fd806ba4 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -587,9 +587,6 @@ namespace IRaCIS.Core.Application.Service saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(IdentityUser)); - saveItem.UserName = saveItem.UserCode; - - saveItem.UserRoleList = new List() { new UserRole() { DoctorId = doctorId, UserTypeEnum = UserTypeEnum.IndependentReviewer, UserTypeId = userType.Id } }; var savedUser = await _identityUserRepository.AddAsync(saveItem); diff --git a/IRaCIS.Core.Infra.EFCore/Context/Convention/NoForeignKeyMigrationsSqlGenerator.cs b/IRaCIS.Core.Infra.EFCore/Context/Convention/NoForeignKeyMigrationsSqlGenerator.cs index 11ff097ee..941930c99 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/Convention/NoForeignKeyMigrationsSqlGenerator.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/Convention/NoForeignKeyMigrationsSqlGenerator.cs @@ -35,18 +35,48 @@ public class NoForeignKeyMigrationsSqlGenerator : SqlServerMigrationsSqlGenerato // 不调用 base.Generate 来跳过生成删除外键的SQL } - ////忽略掉唯一约束 - //protected override void Generate(CreateIndexOperation operation, IModel? model, MigrationCommandListBuilder builder, bool terminate = true) - //{ - // // 如果索引是唯一的,则忽略,不生成SQL语句 - // if (operation.IsUnique) - // { - // return; // 跳过唯一约束的索引创建 - // } + //忽略掉唯一约束 + protected override void Generate(CreateIndexOperation operation, IModel? model, MigrationCommandListBuilder builder, bool terminate = true) + { + //// 如果索引是唯一的,则忽略,不生成SQL语句 + //if (operation.IsUnique) + //{ + // return; // 跳过唯一约束的索引创建 + //} - // // 如果不是唯一索引,则继续生成 - // base.Generate(operation, model, builder, terminate); - //} + //// 如果不是唯一索引,则继续生成 + //base.Generate(operation, model, builder, terminate); + + //// 获取表信息 + //var table = model?.FindEntityType(operation.Table); + //if (table != null) + //{ + // // 跳过主键相关的索引(主键索引以主键列构建) + // var primaryKey = table.FindPrimaryKey(); + // if (primaryKey != null && operation.Columns.SequenceEqual(primaryKey.Properties.Select(p => p.Name))) + // { + // base.Generate(operation, model, builder, terminate); + // return; // 生成主键相关的索引 + // } + //} + + // 检查是否是外键索引 + var table = model?.FindEntityType(operation.Table); + if (table != null) + { + foreach (var foreignKey in table.GetForeignKeys()) + { + // 如果索引列和外键列相同,跳过生成 + if (operation.Columns.SequenceEqual(foreignKey.Properties.Select(p => p.Name))) + { + return; // 跳过生成外键索引 + } + } + } + + // 非外键索引,调用基类方法正常生成 + base.Generate(operation, model, builder, terminate); + }