Example #1
0
        public RecipesService()
        {
            var options = new DbContextOptionsBuilder <RecipesDbContext>()
                          .UseInMemoryDatabase("KittenKatKookie")
                          .Options;

            _context = new RecipesDbContext(options);
        }
Example #2
0
 public static void EnsureSeedData(this RecipesDbContext context)
 {
     if (!seeded && context.Recipes.Count() == 0)
     {
         lock (synchlock)
         {
             if (!seeded)
             {
                 var recipes = GenerateRecipes();
                 context.Recipes.AddRange(recipes);
                 context.SaveChanges();
                 seeded = true;
             }
         }
     }
 }
Example #3
0
 public RecipesService(RecipesDbContext context)
 {
     _context = context;
 }