Olá, nãoNão estou conseguindo atualizar meu objeto. Criei o método da seguinte forma:
failed because another entity of the same type already has the same primary
key value. This can happen when using the 'Attach' method or setting the
state of an entity to 'Unchanged' or 'Modified' if any entities in the graph
have conflicting key values. This may be because some entities are new and
have not yet received database-generated key values. In this case use the
'Add' method or the 'Added' entity state to track the graph and then set
the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.
em System.Data.Entity.Core.Objects.ObjectContext.VerifyRootForAdd(Boolean doAttach, String entitySetName, IEntityWrapper wrappedEntity, EntityEntry existingEntry, EntitySet& entitySet, Boolean& isNoOperation)
em System.Data.Entity.Core.Objects.ObjectContext.AttachTo(String entitySetName, Object entity)
em System.Data.Entity.Internal.Linq.InternalSet`1.<>c__DisplayClassa.<Attach>b__9()
em System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
em System.Data.Entity.Internal.Linq.InternalSet`1.Attach(Object entity)
em System.Data.Entity.Internal.InternalEntityEntry.set_State(EntityState value)
em System.Data.Entity.Infrastructure.DbEntityEntry`1.set_State(EntityState value)
em ProjetoTeste.Infra.Data.Repositories.RepositoryBase`1.Atualizar(T obj) na D:\Informática\Raphael\Projetos VS2015\ProjetoTeste\Codigo\ProjetoTeste\ProjetoTeste.Data\Repositories\RepositoryBase.cs:linha 18
Attaching an entity of type 'ProjetoTeste.Domain.Entities.Clientes.Cliente'
failed because another entity of the same type already has the same primary
key value. This can happen when using the 'Attach' method or setting the
state of an entity to 'Unchanged' or 'Modified' if any entities in the graph
have conflicting key values. This may be because some entities are new and
have not yet received database-generated key values. In this case use the
'Add' method or the 'Added' entity state to track the graph and then set
the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.
em System.Data.Entity.Core.Objects.ObjectContext.VerifyRootForAdd(Boolean doAttach, String entitySetName, IEntityWrapper wrappedEntity, EntityEntry existingEntry, EntitySet& entitySet, Boolean& isNoOperation)
em System.Data.Entity.Core.Objects.ObjectContext.AttachTo(String entitySetName, Object entity)
em System.Data.Entity.Internal.Linq.InternalSet`1.c__DisplayClassa.b__9()
em System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
em System.Data.Entity.Internal.Linq.InternalSet`1.Attach(Object entity)
em System.Data.Entity.Internal.InternalEntityEntry.set_State(EntityState value)
em System.Data.Entity.Infrastructure.DbEntityEntry`1.set_State(EntityState value)
em ProjetoTeste.Infra.Data.Repositories.RepositoryBase`1.Atualizar(T obj) na D:\Informática\Raphael\Projetos VS2015\ProjetoTeste\Codigo\ProjetoTeste\ProjetoTeste.Data\Repositories\RepositoryBase.cs:linha 18
Obrigado!