0
public JsonResult DeleteAjax(int id)
    {
        Product data = (from product in _db.Product
                        where product.Id == id
                        select product).SingleOrDefault();
        _db.Product.DeleteObject(data);
        _db.SaveChanges();
        return Json("Product deleted succsesfully");
    }

VS does not recognize DeleteObject(). Why not?

vcsjones
  • 138,677
  • 31
  • 291
  • 286
emili
  • 9
  • 1
  • possible duplicate: http://stackoverflow.com/questions/17723626/entity-framework-remove-vs-deleteobject – DLeh Aug 28 '14 at 18:19
  • I try with Remove() does not work – emili Aug 28 '14 at 18:29
  • 1
    What do you mean by "does not accept", what error are you getting? No one can help you if you don't ask clearly, give us a clear error message, in full and exactly as it is written – Ronan Thibaudau Aug 28 '14 at 18:37
  • As @RonanThibaudau points out, it is unclear what exactly is happening. Are you getting a compile error for `_db.Product.DeleteObject(data);`, an exception, or what does "not recognize" mean? – Chris Marisic Aug 28 '14 at 18:45
  • 'System.Data.Entity.DbSet' does not contain a definition for 'DeleteObject' and no extension method 'DeleteObject' accepting a first argument of type 'System.Data.Entity.DbSet' could be found (are you missing a using directive or an assembly reference?) – emili Sep 01 '14 at 08:26

0 Answers0