boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

Specify primary key and foreign keys relationship to the Models in ASP.NET MVC

Updated on     Kisan Patel

To demonstrate Primarykey and foreignkey relationship we need two models with primarykey defined and foreignkey defined in them.
we will use
1) parentCategory – Which has Id which is PrimaryKey
2) ChildCategpory – Which has foreign key as “ParentID” that is related with “Id” of ParentCategory table

Now we Create proper model for your database

public class parentCategory 
{
   [Key]
   [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
   public int Id { get; set; }
   
   [Required]
   public string ParentName { get; set; }
}
public class ChildCategpory 
{
   [Key]
   [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
   public int ChildId { get; set; }
   
   [Required]
   public string ChildName{ get; set; }
  
   // Foreign key
   
   [Display(Name = "Parent Name")]
   public int ParentId { get; set; }
   [ForeignKey("ParentId")]
   public virtual ParentCategory Parent { get; set; }
}



ASP.NET MVC

Leave a Reply