public void AddMeal(MealModel mealModel) { using (var context = new HealthContext()) { var day = context.Days.FirstOrDefault(d => d.Created == mealModel.Date); var meal = new Meal { DayId = day.Id, MealNumber = mealModel.MealNumber, MealEntries = mealModel.MealEntries }; context.Add(meal); context.MealEntries.AddRange(meal.MealEntries); context.SaveChanges(); } }