My Model:
[Key,Column(Order = 0)]
[ForeignKey("comp")]
public int comp_num { get; set; }
public virtual Comp Comp { get; set; }
[Key, Column(Order = 1)]
[ForeignKey("Master")]
public string part { get; set; }
public virtual Master Master { get; set; }
public string comp_part_num { get; set; }
My Index page:
-----------------------------------------------------------
-----------------------------------------------------------
@foreach (var item in Model) {
@Html.DisplayFor(modelItem => item.comp)
@Html.DisplayFor(modelItem => item.part)
@Html.DisplayFor(modelItem => item.comp_part_num)
@Html.ActionLink("Edit", "Edit", new { id=item.com }) |
@Html.ActionLink("Details", "Details", new { id = item.comp }) |
@Html.ActionLink("Delete", "Delete", new { id = item.comp })
}
when I use only one key in id it gives the error 'The number of primary key value passed must match number of primary key values defined on the entity'
and also give how to use in controller
public ActionResult Edit(int id = 0)
{
RecordDataView record = db.RecordDataView.Find(id);
if (record == null)
{
return HttpNotFound();
}
return View(record);
}
Someone please help.