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

            _context = new RecipesDbContext(options);
        }
Beispiel #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;
             }
         }
     }
 }
Beispiel #3
0
 public RecipesService(RecipesDbContext context)
 {
     _context = context;
 }