In my database, I have a table called "Site" that contains the column "Site" (please do not ask why :))
I use the first approach to the database. After updating the model from the database, I have a "Site" object with the property "Site1"
public partial class Site
{
...
public string Site1 { get; set; }
...
}
This works fine until I started using the SqlQuery method with a simple choice:
context.Site.SqlQuery("SELECT * FROM dbo.Site WHERE SiteID IN(2,1)").ToArray();
As a result of this, I get an error: “The data reader is not compatible with the specified“ aapModel.Site. ”An element of type“ Site1 ”does not have a corresponding column in the data reader with the same name. '
I found one solution to change the column name in the query:
context.Site.SqlQuery("SELECT Site as Site1 FROM dbo.Site WHERE SiteID IN(2,1)").ToArray();
.
?