Entity Framework nesting classes inside class

asp.net-mvc-5 c# class entity-framework-6 model

Question

I'm attempting to create a data model that enables users to add businesses to a list and then, once added, allows for the addition of further facts about the business, such as staff information. I haven't been able to find out a way to do this without having to make several class, controller, and view folders, however.

The model class file's current version of my code is:

namespace Intranet.Models
{
    public class AddCustomers
    {
        public int AddCustomersID { get; set; }
        public string CompanyName { get; set; }
        ...

        public class EmployeeInfo
        {
            public int EmployeeInfoID { get; set; }
            public string Forename { get; set; }
            ...
        }

        public class ContactInfo
        {
            public int ContactInfoID { get; set; }
            public string Code { get; set; }
            ...
        }
    }
}

Contextual data:

public IntranetContext() : base("name=IntranetContext")
{
}


protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}

public System.Data.Entity.DbSet<Intranet.Models.AddCustomers> AddCustomers { get; set; }
public System.Data.Entity.DbSet<Intranet.Models.AddCustomers.EmployeeInfo> EmployeeInfo { get; set; }
public System.Data.Entity.DbSet<Intranet.Models.AddCustomers.ContactInfo> ContactInfo { get; set; }

However, this is ineffective since the nested classes are only visible in my local database.

Is there a way to make the nested classes visible in each customer's information view? Or is there a totally distinct alternative to this?

1
0
11/17/2017 3:58:22 PM

Accepted Answer

ZZZ_tmp
0
11/17/2017 4:44:19 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow