Error I was getting following error
System.InvalidOperationException: The object cannot be deleted because it was not found in the ObjectStateManager. while trying to delete an object from Entity framework.
Solution The solution of this problem is to find the object using .where clause and then delete it.
var db = db.Users.Where(u => u.UserName.Equals("myusername")).FirstOrDefault();
db.Users.Delete(db);
db.SaveChanges();
Hope this helps.
Thanks
Regards,
Sheo Narayan
http://www.dotnetfunda.com