I am trying to delete an object using Entity Framework and on all the tutorials on the internet I found that in order to do that you have to call the DeleteObject
method on the context. I tried doing that but it seems I have no DeleteObject
methods.
Here is my code:
public void DeleteBook(int bookId)
{
Book book = (Book)bookContext.Books.Where(b => b.Id == bookId).First();
bookContext.DeleteObject(book);
}
This is the error I get:
'DataAccess.Models.BooksEntities' does not contain a definition for 'DeleteObject' and no extension method 'DeleteObject' accepting a first argument of type 'DataAccess.Models.BooksEntities' could be found (are you missing a using directive or an assembly reference?)
What am I doing wrong?
(Book)
cast off theBook
assignment, change theBook
variable tovar
, what type is shown when hovered over? I think you're using the wrong class.