I am trying to delete record from table store but I having problem of recognizing DeleteObject in my code. I have reference
using System.Linq;
using System.Data.Entity;
using System.Data.Objects;
but it still not working. I am using MVC 4 using Visual Studio 2012.
public void Delete()
{
using (var db = new AppContext())
{
var query_D = (from b in db.Stores
where b.storeID == 1
select b).First();
db.DeleteObject(query_D);
db.SaveChanges();
}
}
thanks in advance
I realized that you’re using the MVC 4 with VS2012, and by default the Entity Framework version is 5.
Now the way you
deleteis fromEF4.Here’s the proper way to
deleteusing theEF5