Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created a table(Employee) and inserted sample data,
am getting error in controller


An exception of type 'System.Data.EntityCommandExecutionException' occurred in System.Data.Entity.dll but was not handled in user code

Additional information: An error occurred while executing the command definition. See the inner exception for details.

What I have tried:

my model

C#
public class Employee
    {
        [Key]
        public int EmpID { get; set; }
        public string FullName { get; set; }
        public string FatherName { get; set; }
        public string Gender { get; set; }
        public DateTime DateOfBirth { get; set; }
        public string Mobile { get; set; }
        public String Email { get; set; }
        public string Address { get; set; }
    }


contextmodel

C#
public class EmployeeContext:DbContext
    { 
        public EmployeeContext():base("name=EmployeeContext")
        {
        }

        public DbSet<Employee> Employees { get; set; }
    }



controller


C#
public ActionResult Employee()
       {
           EmployeeContext emp = new EmployeeContext();
           List<Employee> emp1= emp.Employees.ToList();
           return View(emp1);
       }
Posted
Comments
F-ES Sitecore 17-Aug-16 6:18am    
What is the inner exception?
Member 11382784 17-Aug-16 6:36am    
i want to bind data to list
divya behera 18-Aug-16 8:20am    
what is the code for insert function ?
Suvabrata Roy 18-Oct-16 8:18am    
Please share your connection string parameter name

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