Beispiel #1
0
        public async Task InsertMoviesSampleData(MoviesDbContext db)
        {
            var movies = GetMovies();

            db.Movies.AddRange(movies);

            try
            {
                int numAffected = await db.SaveChangesAsync();

                _Logger.LogInformation($"Saved {numAffected} customers");
            }
            catch (Exception exp)
            {
                _Logger.LogError($"Error in {nameof(MoviesDbSeeder)}: " + exp.Message);
                throw;
            }
        }
 public async Task <int> CreateAsync(Movie movie)
 {
     _dbContext.Movies.Add(movie);
     return(await _dbContext.SaveChangesAsync());
 }