I've got a Method that has a Model "Address" as a parameter.
Now inside this method I want to "overwrite" my existing Address in the Database with the provided address - just like updating it in SQL.
I do the inserting-bit like this:
Context.Addresses.AddObject(adr);
Context.SaveChanges();
How do I do the updating-part?
I've tried something like this:
public void Update(Address adr)
{
Context.Addresses.Attach(adr);
Context.SaveChanges();
}
Sadly, this does not work... I've also tried plenty of other codes, but none of them worked.
So how can I update an existing record in my DB when I get an object of the modified record as a parameter?
Thank you
ModelCopierorAutoMapperto update it with the new values, then callSaveChanges().