.net mvc razor dropdowns for foreign keys
问题 Ok, this seemed simple, but is making my head spin. I have created models based on CodeFirst. public class Category { public int ID { get; set; } [StringLength(255, MinimumLength = 1)] public string Name { get; set; } } public class SubCategory { public int ID { get; set; } public Category category { get; set; } [StringLength(255, MinimumLength = 1)] public string Name { get; set; } } Now when i auto-generate the controller and view for SubCategory it (out-of-the-box) lets me create new