private void ReadAnime(IEnumerable <IXLRangeRow> rows) { string[] genres; foreach (var row in rows) { Anime anime = new Anime(); AnimeInfo animeInfo = new AnimeInfo(); anime.Poster = row.Cell(1).Value.ToString(); anime.AnimeName = row.Cell(2).Value.ToString(); anime.Rating = Convert.ToInt32(row.Cell(3).Value); animeInfo.StudioName = row.Cell(4).Value.ToString(); animeInfo.Status = row.Cell(5).Value.ToString(); animeInfo.AgeRating = row.Cell(6).Value.ToString(); animeInfo.Type = row.Cell(7).Value.ToString(); animeInfo.Description = row.Cell(8).Value.ToString(); animeInfo.Source = row.Cell(9).Value.ToString(); animeInfo.Season = row.Cell(10).Value.ToString(); genres = row.Cell(11).Value.ToString().Split(','); if (_context.Animes.Any(an => an.AnimeName == anime.AnimeName) == false) // if anime is already exists { int animeInfoID = AddAnime(anime, animeInfo); DistributeGenres(genres, animeInfoID); _context.SaveChanges(); } } }