Inverse Property on Alternative Key

129 Views Asked by At

Is it possible to create an inverse property based on an alternative key in ef core?

public class Profile 
{
    public int ProfileId { get; set; }

    public int? SubProfileId { get; set; }

    public SubProfile SubProfile {get;set;

    [InverseProperty(nameof(OtherEntity.Profile)]
    public ICollection<OtherEntity> OtherEntities { get; set; }

    // Is there away to achieve this without ef core doing what ef core does "best" 
    // and do funky things, as it does in this case and add "hidden" properties to the sql table?
    [InverseProperty(nameof(OtherSubEntity.SubProfile)]
    public ICollection<OtherSubEntity> OtherSubEntities { get; set; }
}

If I have a entity as defined above is there away to achieve that second inverse property without ef core adding custom properties to OtherSubEntity that it creates in SQL.

0

There are 0 best solutions below