locked
Getting an Error "The column EntityKey was not found on the IDataRecord being evaluated". Entity Framework RRS feed

  • Question

  • Hi,

    I am using Entity framework and Enterprise Library 4.0 to to bind the data from the database.

    I used the following code.

    IRowMapper<VerticalMaster> empRowMapper = MapBuilder<VerticalMaster>.MapAllProperties().Build();

    IParameterMapper empParmMapper = new EmployeeParameterMapper();

    var accessor = new SprocAccessor<VerticalMaster>(db, "sp_GetEmployee", empParmMapper, empRowMapper);

    var result = accessor.Execute(1);

    GridView1.DataSource = result.ToList();

    GridView1.DataBind();

    public class EmployeeParameterMapper : IParameterMapper

    {

    public void AssignParameters(DbCommand command, object[] parameterValues)

    {

    DbParameter parameter = command.CreateParameter();

    parameter.ParameterName = "@EmpID";

    parameter.Value = parameterValues[0];

    command.Parameters.Add(parameter);

    }

    }

    While the code reaches the line "result.ToList()" i am getting the following error 

    "The column EntityKey was not found on the IDataRecord being evaluated. This might indicate that the accessor was created with the wrong mappings."

    Expecting a Suggestion from the experts.

    Thanks & Regards,

    Rocky


    Thursday, March 21, 2013 4:27 PM