I am trying to use Entity Framework and have Automapper update my entity from my contract.

My code looks like this:

var temp = OrderContract;
Order order = dataAccess.FindOne<Order>(x => x.OrderId == temp.OrderId) 
              ?? new Order();

Mapper.Map(OrderContract, order);

if (order.OrderId <= 0)
   dataAccess.Add(order);

(Note: I am using the Repository Pattern. dataAccess.FindOne calls CreateQuery to return one entity.)

The problem I am having is with the relationships. I get this error when I do an update (inserts work just fine):

The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.

I am guessing that automapper is not updating the way I want it to. From the error message and googling around I have surmised that my relationships that are collections (and maybe even the ones that are not collections) are being recreated by Automapper.

How can I tell Automapper to just update and not remake any objects or collections?

Guesses:

I read that maybe I need to use the UseDestinationValue option for automapper. I went back and put that on all my collections But when I do that then my inserts fail with a foreign key violation.

Code Mappings:

Using UseDestinationValue only on one collection (this one inserts but will not update):

//+ Source
Mapper.CreateMap<SourceContract, Source>()
    .IgnoreAllNonExisting();

//+ SelectedRequirement
Mapper.Crea
Edit
Report