sonal malhotra

sonal malhotra

  • NA
  • 410
  • 52.4k

i have issue Another Include() method in mvc

Feb 27 2019 4:02 AM
hello everyone,
 
first i clicked on index razor , it display list of category Electronic n so on ... Error server shown below
 
first model
  1. public partial class categoryTable  
  2. {  
  3. public int CategoryId { getset; }  
  4. public string CategoryName { getset; }  
  5. public string Description { getset; }  
  6. public virtual List<Itemtable> Itemtables { getset; }  
  7. }  
controller
  1. public ActionResult Index()  
  2. {  
  3. var ctx = new shop_cartEntities();  
  4. var category1 = ctx.categoryTables.ToList();  
  5. return View(category1);  
  6. }  
  7. public ActionResult Browser(string category)  
  8. {  
  9. shop_cartEntities ctx = new shop_cartEntities();  
  10. var categorymodel = ctx.categoryTables.Include(c=>c.Itemtables).Single(c => c.CategoryName == category);  
  11. return View(categorymodel);  
Server Error in '/' Application.
A specified Include path is not valid. The EntityType 'shop_cartModel.categoryTable' does not declare a navigation property with the name 'Itemtables'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: A specified Include path is not valid. The EntityType 'shop_cartModel.categoryTable' does not declare a navigation property with the name 'Itemtables'.
 
please help me where i have wrong in include method

Answers (3)