Skip to content

DbSet of type Entity not found on the DbContext #126

Closed
@jaredcnance

Description

@jaredcnance

Combining the context builder with the DbContext generic, fails with the subject error.

services.AddJsonApi<DbContext>(opt => {
  opt.BuildContextGraph(builder => {
    builder.AddResource<MyEntity>("my-entity");
  });
});

Attempting to add the use the non-generic form fails with:

Cannot resolve parameter 'Microsoft.EntityFrameworkCore.DbContext context' of constructor...

A temporary fix is to specify the dbContext in both generics:

services.AddJsonApi<DbContext>(opt => {
  opt.BuildContextGraph(builder => {
    builder.AddDbContext<DbContext>();
    builder.AddResource<MyEntity>("my-entity");
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions