Entity framework trouble

I need to setup a one-to-many relationship with entity framework.

I am trying to build a recipe, but a recipe CAN be composed of recipes.

How to achieve that with EF ?

public class Recipe
{
    public Recipe()
    {
        Deleted = false;

        Recipes = new List<Recipe>();
    }

    [Key]
    public int RecipeId { get; set; }

    public virtual List<Recipe> Recipes { get; set; }
}

I don't need the whole recursive thing(parent, child) only the child I'm interested in. Is it feasible using EF ? Can anyone point me to the right direction

Ex:

Recipe A

Recipe B => A

Recipe C

Recipe D => B

Recipe E => B, C

Answers


This will be a many-to-many relationship, because each recipe can have multiple and multiple parent recipes. When you create your child recipes, you will have to assign a parent to it, so you must define the parent relationship as well.

You could try the InverseProperty dataannotation, for more info check out this question: Entity Framework 4.1 InverseProperty Attribute


Need Your Help

Reset Sequence in oracle 11g

oracle plsql plsqldeveloper

I am trying to reset the sequence to 1 dynamically using the following procedure in oracle 11g.