Skip to main content
tags editadas
Link
Maniero
  • 484,4mil
  • 94
  • 1,3mil
  • 2,2mil
Formatação.
Fonte Link
Leonel Sanches da Silva
  • 89,6mil
  • 9
  • 125
  • 233

Erro ao deletar usando Entity Framework 6 e repositório customizado

Estou usando o padrão de repositório, unity of workunit of work e viewModels;viewModels;

A classe de untiy of workunit of work:

Tenho uma camada de aplicação em que uso o unity of workunit of work:

Mas ai retorna o erro:

Para fazer os testes, eu tava removendo os dados do banco assim, que removia todos...:

Erro ao deletar usando Entity Framework 6

Estou usando o padrão de repositório, unity of work e viewModels;

A classe de untiy of work:

Tenho uma camada de aplicação em que uso o unity of work:

Mas ai retorna o erro:

Para fazer os testes, eu tava removendo os dados do banco assim, que removia todos...:

Erro ao deletar usando Entity Framework 6 e repositório customizado

Estou usando o padrão de repositório, unit of work e viewModels;

A classe de unit of work:

Tenho uma camada de aplicação em que uso o unit of work:

Mas retorna o erro:

Para fazer os testes, eu tava removendo os dados do banco assim, que removia todos:

adicionou 26 caracteres ao conteúdo
Fonte Link
Franchesco
  • 5,3mil
  • 3
  • 28
  • 48

Estou usando o Entity framework para fazer o CRUD no banco de dados, mas tenho um erro ao tentar deletar algum item: "The object cannot be deleted because it was not found in the ObjectStateManager.".

"The object cannot be deleted because it was not found in the ObjectStateManager."

Mas ai retorna o erro: "Attaching an entity of type 'V1.Dominio.Entidades.Usuario' 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."

"Attaching an entity of type 'V1.Dominio.Entidades.Usuario' 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."

Estou usando o Entity framework para fazer o CRUD no banco de dados, mas tenho um erro ao tentar deletar algum item: "The object cannot be deleted because it was not found in the ObjectStateManager.".

Mas ai retorna o erro: "Attaching an entity of type 'V1.Dominio.Entidades.Usuario' 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."

Estou usando o Entity framework para fazer o CRUD no banco de dados, mas tenho um erro ao tentar deletar algum item:

"The object cannot be deleted because it was not found in the ObjectStateManager."

Mas ai retorna o erro:

"Attaching an entity of type 'V1.Dominio.Entidades.Usuario' 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."

Fonte Link
Aesir
  • 1,1mil
  • 3
  • 8
  • 27
Carregando