When I create a Scaffold for the Controller and add the Model class, I get this error " Many sets of objects for each type are not supported ."
I have three Model classes:
1.Department.CS
2.Designation.cs
3.CompanyDBContext.cs
Database: I have two tables in the database, 1. Department (deptID, deptName, Description) 2. Designation (desgtID, desgName, description)
Purpose: - I want to create one view page for this scenario. Like this
Insert form name (TextBox) + Department name (drop-down box) + Name name (drop-down list)
1.Department.CS
namespace mvcAppraisalSystem.Models { public class Department { [Key] public int deptID { get; set; } public string deptName { get; set; } public string Description { get; set; } } }
2.Designation.cs
namespace mvcAppraisalSystem.Models { public class Designation { [Key] public int desgID { get; set; } public string desgName { get; set; } public string description { get; set; } } }
3.CompanyDBContext.cs
namespace mvcAppraisalSystem.Models { public class CompanyDBContext : DbContext { public CompanyDBContext() : base("CompanyDBContext") { } public DbSet<CompanyDBContext> Departments { get; set; } public DbSet<CompanyDBContext> Designations { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); } } }
source share