Why default asp Scaffolding skips some of the model properties while generating 'Create' and 'Edit' views?

有些话、适合烂在心里 提交于 2019-12-12 03:53:34

问题


I am trying to generate a scaffold controller in my project, which is in VS2015 community edition and based on entity framework 6.1.3. Every time I try to do so, it only generates portion of the model. I mean the properties below.

public string Number { get; set; }
    public string Firstname { get; set; }
    public string Surname { get; set; }

model class

public class Students
{
    [Key]
    [ScaffoldColumn(false)]
    public int StudentsID { get; set; }

    [DataType(DataType.Text)]
    [Display(Name = "Student ID")]
    public string Number { get; set; }

    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Firstname")]
    public string Firstname { get; set; }

    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Surname")]
    public string Surname { get; set; }

    [DataType(DataType.Text)]
    [Display(Name = "Date Of Birth")]
    public string DateOfBirth { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Year")]
    public int Year { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Class")]
    public int Class { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Address")]
    public string Address { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Postal code")]
    public string Postalcode { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Doctor Name")]
    public string DoctorName { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Doctor Address")]
    public string DoctorAddress { get; internal set; }
    //[Required]
    [DataType(DataType.Text)]
    [Display(Name = "Doctor Postalcode")]
    public string DoctorPostalcode { get; internal set; }
    [DataType(DataType.Text)]
    [Display(Name = "Meds Info")]
    public string MedsInfo { get; internal set; }



}

Data context

public class SchoolContext : DbContext
{
    public SchoolContext()
        : base("DefaultConnection")
    {
    }
    public DbSet<Students> students { get; set; }


}

I don't know what to do. Same problem occurs, no matter if it is in a new project. My scaffolding controller creation process is below:

来源:https://stackoverflow.com/questions/41149630/why-default-asp-scaffolding-skips-some-of-the-model-properties-while-generating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!