|
Some checks are pending
Publish Platform NuGet Packages / build (push) Waiting to run
修复在 EF Core 10 中使用 JSON 值对象时出现的映射错误:
## 问题
在 EF Core 10 中,GwRouteMatch 类的嵌套集合属性(Headers 和 QueryParameters)
导致 "Unable to determine the relationship" 错误。
## 解决方案
1. 在 PlatformDbContext 中使用 modelBuilder.Ignore<> 忽略相关类型
2. 将 OwnsOne().ToJson() 配置改为使用值转换器(Value Converter)
将对象序列化为 JSON 字符串存储到 jsonb 列
3. 在 GwRouteMatch 类的 Headers 和 QueryParameters 属性上添加 [NotMapped] 特性
4. 添加 [JsonInclude] 特性确保序列化包含这些属性
## 技术细节
- 使用 HasColumnType("jsonb") 存储 JSON 数据
- 使用值转换器处理对象序列化/反序列化
- 保持与 PostgreSQL jsonb 类型的兼容性
## 文件变更
- 修改: Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwRouteMatch.cs
- 修改: Fengling.Platform.Infrastructure/PlatformDbContext.cs
关联任务: IMPL-4 (EF Core 兼容性修复)
关联重构计划: WFS-gateway-refactor
|
||
|---|---|---|
| .. | ||
| Configurations | ||
| ClusterStore.cs | ||
| Extensions.cs | ||
| Fengling.Platform.Infrastructure.csproj | ||
| GatewayExtensions.cs | ||
| GlobalUsings.cs | ||
| IClusterStore.cs | ||
| IRouteManager.cs | ||
| IRouteStore.cs | ||
| ITenantStore.cs | ||
| PlatformDbContext.cs | ||
| RouteManager.cs | ||
| RouteStore.cs | ||
| SeedData.cs | ||
| TenantManager.cs | ||
| TenantStore.cs | ||