Click here to Skip to main content
15,921,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried to insert primary of one table value to table as foreign key value but when i tried to fetch the data of other table where value is stored as foreignvalue iam getting internal server error response is not created .
which one is the right process to fill foreignkey value when we code using webform c# with http verbs by consuming webapi service with entity framework .

What I have tried:

this is my primary key value table data
 public class ADDCATEGORYCLS
   {
       [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
       public ADDCATEGORYCLS()
       {
           this.VEL_ADDROOM = new HashSet<ROOMCLS>();
       }
public int CATEGORY_ID { get; set; }

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage","CA2227:Collectio,PropertiesShouldBeReadOnly")]

public virtual ICollection<ROOMCLS> VEL_ADDROOM { get; set; }


this is foreign key value table code
  public class ROOMCLS
    {
 public Nullable<int> CATEGORY_ID { get; set; }
        public virtual ADDCATEGORYCLS VEL_CATEGORY { get; set; }
}
Posted
Updated 15-Jul-17 19:44pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900