In my mvc asp.net application, I am getting an error in edit function : in given code
public ActionResult Edit(int id)
{
var res = (from r in objeEnti
I had a similar situation with the 'An error occurred while executing the command definition' error. I had some views which were grabbing from another db which used current user security. The second db did not allow the login for the user of the first db causing this issue to occur. I added the db login to the server it was trying to get to from the original server and this fixed the issue. Check your views and see if there are any linked dbs which have different security than the db you are logging onto originally.
After spending hours, I found that I missed 's'
letter in table name
It was [Table("Employee")]
instead of [Table("Employees")]
In my case, I messed up the connectionString
property in a publish profile, trying to access the wrong database (Initial Catalog
). Entity Framework then complains that the entities do not match the database, and rightly so.
Usually this means that your schema and mapping files are not in synch and there is a renamed or missing column someplace.
In my case, It was from Stored Producers. I was removed a field from table and forgotten to remove it from my SP.
Does the actual query return no results? First()
will fail if there are no results.