Error message is :
Invalid column name 'EmployeeId' Invalid column name 'EmployeeId' Invalid column name 'City'.
{
EmployeeContext employeeContext = new EmployeeContext();
Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id); //This line is causing the error
}
But I got exact same database table with all matching columns, why it said I have invalid columns? where did I go wrong? I used codeFirst approach, and actually there are four columns in the table which are EmployeeID, Name, Gender, City, how come I don't have error in Name and Gender but just errors in EmployeeID and City? and error in EmployeeID appear twice?
Detail code
Employee class:
namespace MVCDemo.Models
{
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
}
}
EmployeeContext :
namespace MVCDemo.Models
{
[Table("tblEmployee")]
public class EmployeeContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
}
}
