Updating with Related Entities - Entity Framework v4

Posted by Vincent BOUZON on Stack Overflow See other posts from Stack Overflow or by Vincent BOUZON
Published on 2010-03-28T13:44:40Z Indexed on 2010/03/28 13:53 UTC
Read the original article Hit count: 334

Filed under:
|
|

Hi,

I use Entity Framework V4 and i want to update Customer who have Visits.

My code :

        EntityKey key;
        object originalItem;

        key = this._modelContainer.CreateEntityKey("Customers", customer);

        if (this._modelContainer.TryGetObjectByKey(key, out originalItem))
        {
            this._modelContainer.ApplyCurrentValues(key.EntitySetName, customer);
        }

        this._modelContainer.SaveChanges();

It works for Scalar Property only. The customers.Visits collection is not updated.

Best Regards :)

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about update