try the below method
public bool UpdateProduct(tbl_mainProducts entityChanges, long id)
{
try
{
using (tbl_mainProductsContext dataContext = new tbl_mainProductsContext())
{
var updatedData = mainprod.FirstOrDefault(x=>x.Id==id);
dataContext.Achievement.Attach(updatedData );
dataContext.Entry(updatedData ).State = EntityState.Modified;
dataContext.SaveChanges();
return true;
}
}
catch (Exception exception)
{
return false;
}
}
Hope this helps