Display all records from database using MVC4 with linq

Posted by Mandlaa under ASP.NET MVC on 3/14/2014 | Points: 10 | Views : 1058 | Status : [Member] | Replies : 2
When i am trying to display all records from database using MVC4 it getting an error like below

ERROR:Additional information: Members 'System.String TagId' and 'Int32 ID' both marked as IsPrimaryKey and IsDbGenerated.




Responses

Posted by: Jayakumars on: 3/17/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

post your code here.

Mark as Answer if its helpful to you

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mandlaa on: 3/17/2014 [Member] Starter | Points: 25

Up
0
Down
public ActionResult Products(string searchBy, string search)
{
if (searchBy == "TagNo")
{
return View(db.ProductsHondaofConyers2s.Where(x => x.TagNo == search || search == null).OrderBy(s=>s.TagNo).ToList());
}
else
{
return View(db.ProductsHondaofConyers2s.Where(x => x.StockNo.StartsWith(search) || search == null).OrderBy(s => s.TagNo).ToList());
}
}

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response