[HttpPost]
public ActionResult RemoveCollaborationEntry(int collaborationEntryID = 0)
{
using (var collaborationEntriesContext = new CollaborationEntryContext())
{
collaborationEntriesContext.Collaborations.Remove(
collaborationEntriesContext.Collaborations.ElementAtOrDefault(collaborationEntryID));
collaborationEntriesContext.SaveChanges();
}
return RedirectToAction(nameof(Index));
}
When this method gets invoked, the exception is torwn:
LINQ to Entities does not recognize the method 'annaBevzenkoPortfolioMVC.AboutMe.CollaborationEntry ElementAtOrDefault[CollaborationEntry](System.Linq.IQueryable`1[annaBevzenkoPortfolioMVC.AboutMe.CollaborationEntry], Int32)' method, and this method cannot be translated into a store expression.
I am pretty new to Entity.. can someone help me?
System.Linqnamespace so it can find the extension methodElementAtOrDefault.