Entity Framework Core 6 many-to-many relationship navigation property exclusion

666 Views Asked by At

I have two entities linked that have a many-to-many relationship as shown here:

public class Product
{
    //Omitted code...
    public virtual ICollection<Ingredient> ingredients { get; set; }
}

public class Ingredient
{
    // Omitted code...
    public virtual ICollection<Product> products { get; set; }
}

My question is: I want to load only Product.ingredients navigation property, and I don't want to load the other side of the relation which is ingredient.Products. I want to keep the many-to-many relationship. How can I prevent the ingredient.Products navigation property from being loaded ?

Thanks in advance

0

There are 0 best solutions below