I have the following setup
public class Job
{
public Guid Id { get; set; }
public int? CurrentVersion { get; set; }
public JobVersion JobVersion { get; set; }
}
public class JobVersion
{
public Guid JobId { get; set; }
public int Version { get; set; }
public Job Job { get; set; }
}
I want JobVersion.JobId to be a foreign key to Job.Id. JobVersion.JobId and JobVersion.Version should be a composite key, so that Version increments for every 'group' of JobId If Job.CurrentVersion is not null the JobVersion navigation property should work.
Im trying to create a JobVersion history table, so that only one JobVersion per Job can be active. So if CurrentVersion is changed, the current JobVersion is changed.
I think i have tried all FluentApi setups i can think of, but cant get it to work. Is it possible?
Is there a better approach?