【发布时间】:2013-04-10 12:38:12
【问题描述】:
我们正在寻求为我们的 EF 代码优先数据模型实施版本控制方案。以以下两种模型为例:
public class Question
{
public int Id { get; set; }
public int Version { get; set; }
public string Text { get; set; }
public ICollection<Alternative> Alternatives { get; set; }
}
public class Alternative
{
public int Id { get; set; }
public int Version { get; set; }
public string Text { get; set; }
public bool IsCorrect { get; set; }
public int QuestionId { get; set; }
public virtual Question Question { get; set; }
}
这里的想法是一个问题有多种选择。我们想要链接到问题的Id,而不是Version。同样,一个问题可以引用所有具有QuestionId 等于其Id 的备选方案。
如何最好地建模?随意更改模型。
【问题讨论】:
-
不要模仿 EntityFramework。只需为您的数据库建模,根本无需考虑 EntityFramework。
-
好的。但它仍然需要建模:)
标签: c# entity-framework ef-code-first entity-framework-5