Ejemplo n.º 1
0
        private static void AddRatings(RatingContext context)
        {
            var ratings = Enumerable.Range(0, 100).Select(bookId => new BookRating {
                BookId = bookId, Rating = random.Next(0, 11)
            });

            context.BookRatings.AddRange(ratings);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void Initialize(RatingContext context, bool resetDb)
        {
            if (resetDb)
            {
                context.Database.EnsureDeleted();
            }

            context.Database.Migrate();

            if (context.BookRatings.Any())
            {
                return;
            }

            AddRatings(context);
        }