Diego, Federico,

No deberían usar .Add en lugar de usar .Attach?

        // Summary:
*        //     Adds the given entity to the context underlying the set in
the Added state
        //     such that it will be inserted into the database when
SaveChanges is called.
*        //
        // Parameters:
        //   entity:
        //     The entity to add.
        //
        // Returns:
        //     The entity.
        //
        // Remarks:
        //     Note that entities that are already in the context in some
other state will
        //     have their state set to Added. Add is a no-op if the entity
is already in
        //     the context in the Added state.
        public TEntity Add(TEntity entity);



        //
        // Summary:
*        //     Attaches the given entity to the context underlying the set.
That is, the
        //     entity is placed into the context in the Unchanged state,
just as if it had
        //     been read from the database.*
        //
        // Parameters:
        //   entity:
        //     The entity to attach.
        //
        // Returns:
        //     The entity.
        //
        // Remarks:
        //    * Attach is used to repopulate a context* with an entity that
is known to already
        //     exist in the database.  SaveChanges will therefore not
attempt to insert
        //     an attached entity into the database because it is assumed to
already be
        //     there.  Note that entities that are already in the context in
some other
        //     state will have their state set to Unchanged. Attach is a
no-op if the entity
        //     is already in the context in the Unchanged state.
        public TEntity Attach(TEntity entity);


2011/7/29 Diego Cepero <[email protected]>

> Federico,****
>
> ** **
>
>                 Attach() agrega el objeto al contexto con estado
> “unchanged”. Antes de la llamada a SaveChanges() cambiá su estado a
> “modified”, así:****
>
> ** **
>
>                                 db.Entry(client).State =
> EntityState.Modified;****
>
> ** **
>
>                 Un saludo.****
>
> ** **
>
> *De:* [email protected] [mailto:[email protected]] *En nombre de *Federico
> Sebastian Lazarte
> *Enviado el:* viernes, 29 de julio de 2011 03:08 a.m.
> *Para:* [email protected]
> *Asunto:* [puntonet] Update con EF 4.1 Code First****
>
> ** **
>
> Hola Amigos como estan?.****
>
> Estoy dando mis primeros pasos con EF 4.1 Code First. Por ahora logre armar
> la capa de acceso a datos sin problemas.****
>
> Lo unico que si, es que no logro poder hacer el update de una entidad.****
>
> Mi codigo es el siguiente:****
>
> ** **
>
>         public void Update(Client client)****
>
>         {****
>
>             using (SeoManagerContext db = new SeoManagerContext())****
>
>             {****
>
>  ****
>
>                db.Clients.Attach(client);****
>
>                     db.SaveChanges();****
>
>             }****
>
>         }****
>
> ** **
>
> No me da ningun error, pero, no actualiza los datos en la BD.****
>
> Alguna Idea?.****
>
> Saludos.****
>
> ** **
>
> ** **
>
> ** **
>

Responder a