I am creating an Asp.net MVC application in Which I have Recipe Model
and RecipeCategory
model. I want Recipe model contain foreign key
of RecipeCategory
model. I am new to Entity Framework. I am using code first
approach of Entity framework.
I have recipeCategory
model defined as below:
public class RecipeCategory
{
public int RecipeCategoryID { get; set; }
public string Name { get; set; }
public List<Recipe> Recipe { get; set; }
}
and I have recipe model class like below:
public class Recipe
{
public int ID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public int RecipeCategoryID { get; set; }
public RecipeCategory RecipeCategory { get; set; }
}
What I want:
While creating new Recipe, I want list of Categories in UI to select RecipeCategories but I am unable to get that.
I want properly foreign key established between both tables. please help me solve this