我有两张桌子,Reports
和Visualizations
。Reports
有一个字段 ,VisualizationID
它通过外键指向Visualization
的同名字段。它还具有在字段上声明的唯一键。VisualizationID
不可为空。这意味着关系必须是 0..1 到 1,因为每条 Reports
记录都必须有一个唯一的,而不是Visualizations
与之关联的空记录。
实体框架不这么看。我收到以下错误:
Error 113: Multiplicity is not valid in Role 'Report' in relationship 'FK_Reports_Visualizations'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.
这里有什么问题?如何让 EF 识别正确的关系多重性?