Harlem 98

Harlem 98

  • 1.9k
  • 161
  • 3.7k

System.Data.Objects.ObjectSet does not contain definition "Remove"

Nov 2 2021 4:51 PM

Hello community.

Im having a very confusing error.. I implemented a manual Delete method for deleting rows from a grid. I implemented the method in 2 different classes, in one of them it worked without problems, in the other is throwing the mentioned error

"System.Data.Objects does not contain definition for "Remove" and no extension method "Remove" accepting a first argument of type.... could not be found."

I'm using the namespace System.entity.data... Do you have any ideias on the problem, or equivalent alternatives for delete method (used through BLL logic in TelerikRadGrid with Delete Command)

public void DeleteFile(int ID)
{
try
{
using (GPEntities lt = new GPEntities())
{
ListagemTimesheet ddelete = lt.ListagemTimesheets.Find(ID);
lt.ListagemTimesheets.Remove(ddelete);
lt.SaveChanges();
}
}

 


Answers (8)