您好我正在使用MVCScaffolding,MySQL有点痛苦,但我有这个:
public class SubCategories
{
[Key, Display(Name = "ID"), HiddenInput(DisplayValue = false), Required]
public Int32 SubCategoriesId { get; set; }
[Required, Display(Name = "Name")]
public string SubCategoriesName { get; set; }
[Required, Display(Name = "Active")]
public bool SubCategoriesShow { get; set; }
[Required, Display(Name = "Category")]
public Int32 CategoriesId { get; set; }
[ScaffoldColumn(false)]
public virtual Categories Categories { get; set; }
}
和
public class Categories
{
[Key, Display(Name = "ID"), HiddenInput(DisplayValue = false), Required]
public Int32 CategoryId { get; set; }
[Required,Display(Name = "Name")]
public string CategoryName { get; set; }
[Required,Display(Name = "Active")]
public bool CategoryShow { get; set; }
}
这很好,当我添加一个子类别时,它会创建一个类别的dropdwon,但它也创建了我不想要的列Category_CategoriesId,我试图将脚手架设置为false但是这个doesent似乎工作了
非常感谢
感谢
答案 0 :(得分:1)
我不确定,[Column(“name”)]怎么样? 我想为你已经解决的问题添加[可编辑(假)]。
帮你关闭它
将[ForeignKey(“CategoriesId”)]添加到子类别中的虚拟类别会修复它。