【发布时间】:2016-04-12 00:04:02
【问题描述】:
我正在尝试创建一个带有图像上传字段和名称字段的表单,并使用视图模型进行验证(见下文)。问题是当我迁移我的数据库以考虑此类或在 Visual Studio(启动站点)中点击播放时,我收到以下错误:
InvalidOperationException: The property 'ImageUpload' on entity type 'BallWallWebApp.ViewModels.Slides.CreateSlideViewModel' has not been added to the model or ignored.
Microsoft.Data.Entity.Metadata.Conventions.Internal.PropertyMappingValidationConvention.Apply(InternalModelBuilder modelBuilder)
代码:
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace BallWallWebApp.ViewModels.Slides
{
public class CreateSlideViewModel
{
[Required]
public int WallId { get; set; }
[Required]
[Display(Name = "Slide Name")]
[DataType(DataType.Text)]
public string Name { get; set; }
[Required]
[Display(Name = "Slide image file")]
[DataType(DataType.Upload)]
public IFormFile ImageUpload { get; set; }
}
}
我错过了什么?
【问题讨论】:
标签: c# asp.net asp.net-core asp.net-core-mvc