public void SaveTvSeries(TvSeries tvSeries) { _validationContext.ValidateAnnotations(tvSeries); _validationContext.ThrowIfHasErrors(); // Episodes[0].Title : StringLength - The field Ttile must be a string with a maximum length of 40 // Episodes[1].Title : NonUniqueTitle - Episode 1 has non unique Title field _dbContext.Series.Add(tvSeries); for (int i = 0; i < tvSeries.Episodes.Count; i++) { using (_validationContext.WithPrefix($"Episodes[{i}]")) { SaveEpisode(tvSeries.Episodes[i]); } } _validationContext.ThrowIfHasErrors(); // Episodes[0].ActorIds : HasUnknownActors - Episode 0 has unknown actors // Episodes[1].ActorIds : HasUnknownActors - Episode 1 has unknown actors _dbContext.SaveChanges(); }