【发布时间】:2020-05-28 22:32:25
【问题描述】:
我是 EFC 的新手,希望能在遇到的问题上获得帮助。 假设我有两张桌子:
工具台:
Version FeatureId
1 1
1 2
1 4
2 1
特征表:
FeatureId Name
1 feature1
2 feature2
3 feature3
4 feature4
根据这两张表,我有以下几点:
public class Tool
{
public int Id {get; set;}
public int Version { get; set; }
public List<Feature> Features { get; set; }
}
public class Feature
{
public string FeatureId { get; set; }
public string Name { get; set; }
}
因此,一个工具版本可能包含多个功能,并且一个功能可能包含在多个版本中。当我尝试根据版本号检索工具时,如下所示:
_context.Tool.Where(x => x.Version == versionID)
.Include(i => i.Features)
.ToList()
我在询问 ToolId 时遇到了错误。这是为什么?
【问题讨论】:
-
尝试将
public List<Tool> Tools { get; set; }添加到您的Feature课程中 -
@GuruStron,谢谢。我收到“路径解析器错误。/api/tool.get.responses.200.content.application/json.schema.properties.features.items.properties.tools.items.properties.features.items.$ref 无法解析如果我按照建议添加了工具列表,请大摇大摆地参考:未找到”。
-
不确定是否与EF有关系=)
标签: c# .net entity-framework asp.net-core entity-framework-core