Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
namespace MvcApplication6.Models
{
    [Table("tblEmployee")]
    public class Employee
    {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Gender { get; set; }
        public string City { get; set; }
    }
}

public class EmployeeContext:DbContext
    {
      public  DbSet<employee>Employees{get;set;}
    }


EmployeeController

public ActionResult Details(int id)
{
EmployeeContext employeeContext = new EmployeeContext();
Employee employees= employeeContext.Employees.Single(emp => emp.EmployeeId == id);
return View(employees);
}
am getting ERROR at id i.e" entity command execution exception was unhandled by user code".
i mentioned connection string alsocould you please send me solution...

What I have tried:

am getting ERROR at id i.e" entity command execution exception was un handled by user code".
i mentioned connection string also could you please send me solution...</employee>
Posted
Comments
[no name] 4-Mar-16 2:29am    
Are you sure the value of id is present in your database?
Richard Deeming 4-Mar-16 5:32am    
Post the full exception details, including any inner exceptions.

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