private void SaveResizedImagesInDB(Image userImage, ResizedImageInfo imageInfo) { using (var db = new ImageContext()) { var ResizedImage = new ResizedImage() { ParentId = userImage.Id, FileName = imageInfo.FileName, FilePath = Url.Content("~/Images/" + imageInfo.FileName), PreviewPath = userImage.PreviewPath, Height = imageInfo.Height, Width = imageInfo.Width, StartTime = imageInfo.StartTime, FinishTime = imageInfo.FinishTime }; try { db.ResizedImages.Add(ResizedImage); db.SaveChanges(); userImage.ResizedImages.Add(new ResizedImageWithPreview(ResizedImage)); } catch (Exception ex) { } } }