I have this piece of code but it does not work, and I do not see where id the problem.
No exception is caught.
I'm working with Entity Framework 4. The SaveChanges
call does not seem do anything in the database.
try
{
Demande_Rage_Animale editdemande = DemandeRageAnimaleDAO.First(s => s.ID == demandebean.ID);
//frombeanTodemande(demandebean, editdemande);
editdemande.num_rapport = "111111";
//editdemande.EntityState.
DemandeRageAnimaleDAO.SaveChanges();
}
catch (Exception ex)
{
Logger.Error("==> Modifier_demande_RageAnimale : " + ex.InnerException);
}
You must mark the entity as modified before calling SaveChanges:
In older versions of Entity Framework you can use this:
It's possible that the method shown in the question is not the full picture and perhaps the entity has become detached. In this case you can attach it back to the context, mark it as modified and call SaveChanges: