I would use foreign keys for this. As you said, a recipe has multiple ingredients. In Entity Framework this would be:
public class Recipe
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
// ...
public virtual ICollection<Recipe> Recipies { get; set; }
}
public class Ingredient
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Amount { get; set; }
public string Unit { get; set; }
public virtual Recipe Recipe { get; set; }
public int RecipeId { get; set; }
}
Like this you can have a recipe 'Pancaces for 2' with ingredients like '2 Eggs', '50g flour', '1/4 cup buttermilk', ...
Hope I understood your question correctly.
EDIT1:
I would not suggest to store all the ingredients in a single column, what's why I made an example for how to do it with foreign keys. How you would store this (supposed you're creating a new recipe) in a controller. It would be something like this:
public ActionResult Post(string recipyName, string[] ingredients)
{
var recipy = new Recipy
{
Name = recipyName,
Ingredients = ingredients.Select(x => new Ingredient
{
Name = x,
Unit = "pcs.",
Amount = 1,
}).ToList(),
}
using (var context = new RecipyContext())
{
context.Recipes.Add(recipy);
context.SaveChanges();
}
return Ok();
}
I really suggest not to store the ingredients in a single column. It is not extensible and you would have to do some kind of string trickery to get them out again. Like this everything is clear to everyone who reads your code.
EDIT2: I think this thread Asp.net razor textbox array for list items shows how to integrate such a model into the view rather nicely.