@@ -27,12 +27,46 @@ public void Seed()
2727 dbContext . Set < IngredientEntity > ( ) . Add ( IngredientSeeds . Water ) ;
2828 }
2929
30+ foreach ( var ingredient in new [ ]
31+ {
32+ IngredientSeeds . Tomato , IngredientSeeds . Onion , IngredientSeeds . Garlic ,
33+ IngredientSeeds . OliveOil , IngredientSeeds . Salt , IngredientSeeds . GroundBeef ,
34+ IngredientSeeds . Spaghetti , IngredientSeeds . ChickenBreast , IngredientSeeds . BellPepper ,
35+ IngredientSeeds . SoySauce , IngredientSeeds . Banana , IngredientSeeds . Milk ,
36+ IngredientSeeds . Honey , IngredientSeeds . Flour , IngredientSeeds . Egg ,
37+ IngredientSeeds . Butter , IngredientSeeds . ChocolateChips , IngredientSeeds . Sugar ,
38+ IngredientSeeds . Carrot , IngredientSeeds . Potato , IngredientSeeds . Beef ,
39+ IngredientSeeds . CocoaPowder , IngredientSeeds . Bread ,
40+ } )
41+ {
42+ if ( ! dbContext . Set < IngredientEntity > ( ) . Any ( i => i . Id == ingredient . Id ) )
43+ {
44+ dbContext . Set < IngredientEntity > ( ) . Add ( ingredient ) ;
45+ }
46+ }
47+
3048 if ( ! dbContext . Set < RecipeEntity > ( ) . Any ( i => i . Id == RecipeSeeds . LemonadeRecipe . Id ) )
3149 {
3250 dbContext . Set < RecipeEntity > ( ) . Add (
3351 RecipeSeeds . LemonadeRecipe with { Ingredients = new List < IngredientAmountEntity > ( ) } ) ;
3452 }
3553
54+ foreach ( var recipe in new [ ]
55+ {
56+ RecipeSeeds . TomatoSoupRecipe , RecipeSeeds . SpaghettiBoLogneseRecipe ,
57+ RecipeSeeds . ChickenStirFryRecipe , RecipeSeeds . BananaSmoothieRecipe ,
58+ RecipeSeeds . ChocolateChipCookiesRecipe , RecipeSeeds . ScrambledEggsRecipe ,
59+ RecipeSeeds . PancakesRecipe , RecipeSeeds . BeefStewRecipe ,
60+ RecipeSeeds . HotChocolateRecipe , RecipeSeeds . GarlicBreadRecipe ,
61+ } )
62+ {
63+ if ( ! dbContext . Set < RecipeEntity > ( ) . Any ( r => r . Id == recipe . Id ) )
64+ {
65+ dbContext . Set < RecipeEntity > ( ) . Add (
66+ recipe with { Ingredients = new List < IngredientAmountEntity > ( ) } ) ;
67+ }
68+ }
69+
3670 if ( ! dbContext . Set < IngredientAmountEntity > ( ) . Any ( i => i . Id == IngredientAmountSeeds . LemonadeLemon . Id ) )
3771 {
3872 dbContext . Set < IngredientAmountEntity > ( ) . Add (
@@ -45,6 +79,43 @@ public void Seed()
4579 IngredientAmountSeeds . LemonadeWater with { Recipe = null ! , Ingredient = null ! } ) ;
4680 }
4781
82+ foreach ( var ia in new [ ]
83+ {
84+ IngredientAmountSeeds . TomatoSoupTomato , IngredientAmountSeeds . TomatoSoupOnion ,
85+ IngredientAmountSeeds . TomatoSoupGarlic , IngredientAmountSeeds . TomatoSoupOliveOil ,
86+ IngredientAmountSeeds . TomatoSoupSalt ,
87+ IngredientAmountSeeds . SpagBolGroundBeef , IngredientAmountSeeds . SpagBolSpaghetti ,
88+ IngredientAmountSeeds . SpagBolTomato , IngredientAmountSeeds . SpagBolOnion ,
89+ IngredientAmountSeeds . SpagBolGarlic , IngredientAmountSeeds . SpagBolOliveOil ,
90+ IngredientAmountSeeds . StirFryChickenBreast , IngredientAmountSeeds . StirFryBellPepper ,
91+ IngredientAmountSeeds . StirFryOnion , IngredientAmountSeeds . StirFrySoySauce ,
92+ IngredientAmountSeeds . StirFryGarlic ,
93+ IngredientAmountSeeds . SmoothieBanana , IngredientAmountSeeds . SmoothieMilk ,
94+ IngredientAmountSeeds . SmoothieHoney ,
95+ IngredientAmountSeeds . CookiesFlour , IngredientAmountSeeds . CookiesButter ,
96+ IngredientAmountSeeds . CookiesSugar , IngredientAmountSeeds . CookiesEgg ,
97+ IngredientAmountSeeds . CookiesChocolateChips ,
98+ IngredientAmountSeeds . ScrambledEggsEgg , IngredientAmountSeeds . ScrambledEggsButter ,
99+ IngredientAmountSeeds . ScrambledEggsMilk , IngredientAmountSeeds . ScrambledEggsSalt ,
100+ IngredientAmountSeeds . PancakesFlour , IngredientAmountSeeds . PancakesEgg ,
101+ IngredientAmountSeeds . PancakesMilk , IngredientAmountSeeds . PancakesButter ,
102+ IngredientAmountSeeds . PancakesSugar ,
103+ IngredientAmountSeeds . StewBeef , IngredientAmountSeeds . StewCarrot ,
104+ IngredientAmountSeeds . StewPotato , IngredientAmountSeeds . StewOnion ,
105+ IngredientAmountSeeds . StewGarlic ,
106+ IngredientAmountSeeds . HotChocMilk , IngredientAmountSeeds . HotChocCocoaPowder ,
107+ IngredientAmountSeeds . HotChocSugar , IngredientAmountSeeds . HotChocHoney ,
108+ IngredientAmountSeeds . GarlicBreadBread , IngredientAmountSeeds . GarlicBreadButter ,
109+ IngredientAmountSeeds . GarlicBreadGarlic ,
110+ } )
111+ {
112+ if ( ! dbContext . Set < IngredientAmountEntity > ( ) . Any ( i => i . Id == ia . Id ) )
113+ {
114+ dbContext . Set < IngredientAmountEntity > ( ) . Add (
115+ ia with { Recipe = null ! , Ingredient = null ! } ) ;
116+ }
117+ }
118+
48119 dbContext . SaveChanges ( ) ;
49120 }
50121}
0 commit comments