We are looking to implement a versioning scheme for our EF Code first data models. Take the following two models as an example:
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; }
}
Here, the idea is that a question has multiple alternatives. We want to link an alternative to a question's Id, but not its Version. Likewise, a question can get a reference to all alternatives which has a QuestionId equal to its Id.
How would this be modeled best? Feel free to change the models.