“The data reader has more than one field” error in Entity Framework

前端 未结 4 1703
我寻月下人不归
我寻月下人不归 2020-12-10 00:42

I\'m executing this simple query with Entity Framework

db.Database.SqlQuery(\"SELECT * FROM hospital\");

But I got this error

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 01:33

    Based on the secound answer that cgotberg gave me, Im going to answer my own question. The problem with that code was that some table's field was not the same as it is in the database(I was looking for the exception but I could not found it, sorry for that) but it actually exist. For some reason i had to add all the fields of the tables to the query string. I mean, i had to write "SELECT hospital_phone, holpital_street, etc, etc FROM hospital", if i write "SELECT hospital_name FROM hospital" the exception occurs.

    Hope I've it explained well.

提交回复
热议问题