Skip to content

Entity state "Detached" #11

@Henning34

Description

@Henning34

When fetching an entity using the cache the entity state is "Detached" and not "Unchanged" as expected.

Steps to reproduce

A first call to

var product = _context.Product.Where(p => p.Id == request.ProductID).Cacheable(TimeSpan.FromMinutes(10)).FirstOrDefault();
var state = _context.Entry(product).State;

Has the result: "Unchanged"

The second call (using the cache) results in : "Detached" !

When using the product reference as relation, the next call to SaveChanges() fails as it tries to insert the entity a second time.

Further technical details

Using the cache in an asp.net core application with dependency injection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions