I have two class :
class Sub
{
public Guid Id { get; set; }
public DateTime ValidDate { get; set; }
public Guid MasterId { get; set; }
public Master Master { get; set; }
}
and
class Master
{
public Guid Id { get; set; }
public int Data { get; set; }
public ICollection<Sub> Subs { get; set; }
public Sub MainSub { get; set; }
}
To be simple, a master have a main sub to define it, and can have 0 or more "secondary" subs. I've tried to do mapping this way
var mBuilder = modelBuilder.Entity<Master>();
mBuilder.HasMany(m => m.Subs).WithOne(m => m.Master).HasForeignKey(m => m.MasterId);
mBuilder.HasOne(m => m.MainSub).WithOne(m => m.Master);
but I have an exception as expected ("Master cannot participate in two relationships"). I don't want to change my model cause it fits what I need, how can I perform such a mapping to do so ?