I have tried these two ways.
1
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)// el id llega con toda normalidad
{
db.Entry(db.Detalle.Find(id)).State = EntityState.Deleted;
db.SaveChanges();
return RedirectToAction("Index");
}
2
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id) // el id llega con toda normalidad
{
Detalle idar = db.Detalle.Find(id);
db.Detalle.Remove(idar);
db.SaveChanges();
return RedirectToAction("Index");
}
and both give me the same error
The user code did not control System.ArgumentNullException HResult = -2147467261 Message = The value can not be null. Parameter name: entity ParamName = entity Source = EntityFramework StackTrace: in System.Data.Entity.ModelConfiguration.Utilities.RuntimeFailureMethods.Requires (Boolean condition, String userMessage, String conditionText) in System.Data.Entity.DbSet
1.Remove(TEntity entity) en SIGA.net.Controllers.ArqueoController.DeleteConfirmed(Int32 id) en C:\Proyectos\SIGA.net\SIGA.net\Controllers\ArqueoController.cs:línea 173 en lambda_method(Closure , ControllerBase , Object[] ) en System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) en System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) in System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary% co_of% 1.b__7 (IAsyncResult _) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult'1.End () in System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (IAsyncResult asyncResult) in System.Web.Mvc.Async.AsyncControllerActionInvoker. < > c__DisplayClass37. < > c__DisplayClass39.b__33 () in System.Web.Mvc.Async.AsyncControllerActionInvoker. < > c__DisplayClass4f.b__49 () InnerException: