Our team uses Entity Framework 4.1 ORM. We do not use it in Code First mode, but we use pure POCO generation functions from this version.
We are faced with the fact that we want to create an inherited class based on EF POCO, but for now the only way to see this is to have a mapping table in the database. Is there a better way to create this inherited object? The following code is an example of what I'm talking about.
This class is generated:
public partial class Member { public Member() { this.ContactAddresses = new HashSet<ContactAddress>(); this.ContactEmails = new HashSet<ContactEmail>(); this.FormDatas = new HashSet<FormData>(); this.ContactPhones = new HashSet<ContactPhone>(); } public int ID { get; set; } public string FirstName { get; set; } public string MiddleName { get; set; } public string LastName { get; set; } public string Alias { get; set; } public string Title { get; set; } public string Company { get; set; } public string Prefix { get; set; } public string Suffix { get; set; } public System.DateTime CreatedDate { get; set; } public int CreatedBy { get; set; } public Nullable<System.DateTime> ModifiedDate { get; set; } public Nullable<int> ModifiedBy { get; set; } public Nullable<System.Guid> AspNetUserID { get; set; } public virtual aspnet_Users aspnet_Users { get; set; } public virtual ICollection<ContactAddress> ContactAddresses { get; set; } public virtual ICollection<ContactEmail> ContactEmails { get; set; } public virtual ICollection<FormData> FormDatas { get; set; } public virtual ICollection<ContactPhone> ContactPhones { get; set; } }
This is an example of what we would like to create:
public class SpecificMember : Member { public SpecificMember() { this.Assignments = new HashSet<Assignment>(); this.Expertises = new HashSet<Expertise>(); this.Experiences = new HashSet<Experience>(); }this.VendorInformations = new HashSet<VendorInformation>(); public virtual ICollection<Assignment> Assignments { get; set; } public virtual ICollection<Expertise> Expertises { get; set; } public virtual ICollection<Experience> Experiences { get; set; } public virtual ICollection<VendorInformation> VendorInformations { get; set; } }
I would really like to stay away from placing another table in the database. My idea is that we only deal with classes, but I'm not sure how these two objects will work with each other.
Any ideas on how to accomplish this when using the Entity Framework or in code would be great. Thanks in advance.
Chris source share