不生成外键测试
parent
eca91b139b
commit
bb9c7066c7
|
|
@ -3523,6 +3523,13 @@
|
|||
UserFeedBackService
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.UserFeedBackService.SetUserFeedBackState(IRaCIS.Core.Application.ViewModel.SetUserFeedBackStateInDto)">
|
||||
<summary>
|
||||
设置用户反馈状态 并且可以提供理由
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.UserFeedBackService.BatchUpdateFeedBackState(IRaCIS.Core.Application.ViewModel.BatchUpdateCommand)">
|
||||
<summary>
|
||||
批量更新状态
|
||||
|
|
@ -17299,12 +17306,22 @@
|
|||
<member name="T:IRaCIS.Core.Application.ViewModel.UserFeedBackView">
|
||||
<summary> UserFeedBackView 列表视图模型 </summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.SetUserFeedBackStateInDto.Reason">
|
||||
<summary>
|
||||
原因
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.ViewModel.UserFeedBackQuery">
|
||||
<summary>UserFeedBackQuery 列表查询参数模型</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.ViewModel.UserFeedBackAddOrEdit">
|
||||
<summary> UserFeedBackAddOrEdit 列表查询参数模型</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.UserFeedBackAddOrEdit.Reason">
|
||||
<summary>
|
||||
原因
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.ViewModel.UserLogView">
|
||||
<summary> UserLogView 列表视图模型 </summary>
|
||||
</member>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
if (inQuery.Id == null && inQuery.VisitTaskId == null)
|
||||
{
|
||||
throw new BusinessValidationFailedException("Id 或者VisitTaskId 必传一个");
|
||||
throw new BusinessValidationFailedException("The interface parameter Id or VisitTaskId cannot be passed at the same time");
|
||||
}
|
||||
|
||||
var result = await _userFeedBackRepository
|
||||
|
|
|
|||
|
|
@ -61,23 +61,51 @@ public class NoForeignKeyMigrationsSqlGenerator : SqlServerMigrationsSqlGenerato
|
|||
//}
|
||||
|
||||
// 检查是否是外键索引
|
||||
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; // 跳过生成外键索引
|
||||
}
|
||||
}
|
||||
}
|
||||
//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; // 跳过生成外键索引
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
if (IsForeignKeyIndex(operation, model))
|
||||
return;
|
||||
|
||||
// 非外键索引,调用基类方法正常生成
|
||||
base.Generate(operation, model, builder, terminate);
|
||||
}
|
||||
private bool IsForeignKeyIndex(CreateIndexOperation operation, IModel? model)
|
||||
{
|
||||
var entity = model?
|
||||
.GetEntityTypes()
|
||||
.FirstOrDefault(e =>
|
||||
e.GetTableName() == operation.Table &&
|
||||
e.GetSchema() == operation.Schema);
|
||||
|
||||
if (entity == null)
|
||||
return false;
|
||||
|
||||
var tableId = StoreObjectIdentifier.Table(operation.Table, operation.Schema);
|
||||
|
||||
foreach (var fk in entity.GetForeignKeys())
|
||||
{
|
||||
var cols = fk.Properties
|
||||
.Select(p => p.GetColumnName(tableId))
|
||||
.ToArray();
|
||||
|
||||
if (cols.SequenceEqual(operation.Columns))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ public class IRaCISDBContext : DbContext
|
|||
//https://learn.microsoft.com/zh-cn/ef/core/modeling/relationships/conventions?utm_source=chatgpt.com
|
||||
configurationBuilder.Conventions.Remove(typeof(ForeignKeyIndexConvention));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
|
|
|||
Loading…
Reference in New Issue