I have two entities DataTag and CalcDataTag:
public class CalcDataTag : BaseModel
{
[Column("CalcDataTagId")]
public override Guid ID { get; set; }
public Guid DataTagId { get; set; }
public DataTag DataTag { get; set; }
public Guid ChildDataTagId { get; set; }
public DataTag ChildDataTag { get; set; }
}
public class DataTag : BaseModel
{
[Column("DataTagId")]
public override Guid ID { get; set; }
public ICollection<CalcDataTag> CalcDataTags { get; set; }
}
I set the context up like this:
modelBuilder.Entity<DataTag>()
.HasMany<CalcDataTag>(x => x.CalcDataTags)
.WithRequired(x => x.ChildDataTag)
.HasForeignKey(x => x.ChildDataTagId);
modelBuilder.Entity<DataTag>()
.HasMany<CalcDataTag>(x => x.CalcDataTags)
.WithRequired(x => x.DataTag)
.HasForeignKey(x => x.DataTagId);
The CalcDataTags list should be a list of CalcDataTags where either the DataTagId or the ChildDataTagId is equal to the DataTag's ID but the way the context is set up, the bottom setting overrides the top setting and I only get a list of CalcDataTags where the DataTagId is equal to the DataTag's ID. If I switch the settings then I only get a list of CalcDataTags where the ChildCalcDataTagId is equal to the DataTag's ID. Basically what I am trying to get is a union of the two lists. Each entity only has one PrimaryKey, no composite keys.