I have the following classes:
public class Condition
{
public int Id {get;set; }
public Condition ParentCondition {get;set;}
public Action ParentAction {get;set;}
public string Whatever {get;set;}
}
public class Action
{
public int Id {get;set; }
public Condition ParentCondition {get;set;}
public Action ParentAction {get;set;}
public string Whatever {get;set;}
}
So both, the condition and the action may have either a condition or an action as a parent (or none if both are null)
I tried to put this onto a SQL database but lost somehow. So something I would want to achieve would be something like (pseudo code)
TABLE Condition
:
int ConditionParent
int ActionParent
Table Action
:
int ConditionParent
int ActoinParent
I tried using fluent api:
modelBuilder.Entity<Condition>()
.ToTable("Condition")
.HasOptional(c => c.ParentAction)
.WithRequired(a => a.ParentCondition);
But when I do this, the Action
table looks fine, but the migration code for the condition has no column for an action parent at all.
What has to be changed?