An association from the table orch_eProp_Company_ContactPartRecord refers to an unmapped class: eProp.Company.Models.CompanyPart

Topics: Customizing Orchard
Jan 8, 2012 at 4:41 PM

Hi,

I have two table called company and contact.  contact table include companies contcat persons name

I have created 2 handlers and driver and controller for this two table handling, Its raise this error

An association from the table orch_eProp_Company_ContactPartRecord refers to an unmapped class: eProp.Company.Models.CompanyPart

 

why it happen?

 

lakmal


 

Jan 10, 2012 at 4:17 AM

Hi,

I have created separate model for contact

Here its 

 

namespace eProp.Company.Models
{   

    public class ContactPartRecord :ContentPartRecord
    {
        public virtual string Name { get; set; }
        public virtual string Email { get; set; }
        public virtual string Telephone { get; set; }
        public virtual string Cell { get; set; }
        public virtual CompanyPart  CompanyPart { get; set; }


    }


    public class ContactPart : ContentPart<ContactPartRecord>
    {
        public string Name 
        { 
            get{return Record.Name ;}

            set {Record.Name =value  ;}
        }

        public string Email {

            get {return Record.Email  ;}

            set { Record.Email=value ; }
        }
        public string Telephone 
        {
            get { return Record.Telephone ;}
            set { Record.Telephone=value ; }
        }
        public string Cell 
        {
            get {return Record.Cell  ;}

            set { Record.Cell=value ; }
        }
        public CompanyPart CompanyPart 
        {
            get { return Record.CompanyPart; }

            set { Record.CompanyPart = value; }
        }


    }

    
}

 

But its finding wrong model. Its should find Contact, but its finding Company, Why that?

 

lakmal

Jan 12, 2012 at 3:00 AM

I have change my model like below, Then its working

 

public class ContactPartRecord :ContentPartRecord
    {
        public virtual string Name { get; set; }
        public virtual string Email { get; set; }
        public virtual string Telephone { get; set; }
        public virtual string Cell { get; set; }
        public virtual int  CompanyPartRecord_Id { get; set; }


    }

    public class ContactPart : ContentPart<ContactPartRecord>
    {
        public string Name 
        { 
            get{return Record.Name ;}

            set {Record.Name =value  ;}
        }

        public string Email {

            get {return Record.Email  ;}

            set { Record.Email=value ; }
        }
        public string Telephone 
        {
            get { return Record.Telephone ;}
            set { Record.Telephone=value ; }
        }
        public string Cell 
        {
            get {return Record.Cell  ;}

            set { Record.Cell=value ; }
        }
        public int CompanyPartRecord_Id 
        {
            get { return Record.CompanyPartRecord_Id; }
            set { Record.CompanyPartRecord_Id = value; }
           
        }


    }