0

I wrote a query in Entity Framework, as:

var query1 = database.Database.SqlQuery<customer>("select name from customer where shomaremoshtare ='" + txt_shomaremoshtare.Text.Trim() + "'");

When I run this, I get this error:

The data reader is incompatible with the specified 'moavaghatModel.customer'. A member of the type, 'id', does not have a corresponding column in the data reader with the same name.

William Robertson
  • 15,273
  • 4
  • 38
  • 44
ehsankhan
  • 13
  • 2

1 Answers1

0

You are returning only the name of the entity in your select, try to return all the fields like this:

var query1 = database.Database.SqlQuery<customer>("select * from customer where shomaremoshtare ='" + txt_shomaremoshtare.Text.Trim() + "'");