コード例 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RecipeContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RecipeContext> >()))
            {
                // Look for any movies.
                if (context.Recipe.Any())
                {
                    return;   // DB has been seeded
                }

                context.Recipe.AddRange(
                    new Recipe
                {
                    Name        = "Carne Asada",
                    CreatedDate = DateTime.Now,
                    Type        = "Mexican",
                    CreatedBy   = "Jorge Luis"
                },

                    new Recipe
                {
                    Name        = "Sukiyaki",
                    CreatedDate = DateTime.Now,
                    Type        = "Japanese",
                    CreatedBy   = "Adriana"
                },

                    new Recipe
                {
                    Name        = "French Toast",
                    CreatedDate = DateTime.Now,
                    Type        = "Breakfast",
                    CreatedBy   = "Jorge Luis"
                }
                    );
                context.SaveChanges();
            }
        }
コード例 #2
0
 public IndexModel(FamilyRecipes.Models.RecipeContext context)
 {
     _context = context;
 }
コード例 #3
0
 public EditModel(FamilyRecipes.Models.RecipeContext context)
 {
     _context = context;
 }
コード例 #4
0
 public DetailsModel(FamilyRecipes.Models.RecipeContext context)
 {
     _context = context;
 }
コード例 #5
0
 public CreateModel(FamilyRecipes.Models.RecipeContext context)
 {
     _context = context;
 }