āœ… Unable to create a 'DbContext' of type 'ApplicationDbContext'.

hi šŸ‘‹
i'm trying to structure my project with DDD model
but getting this error:
Unable to create a 'DbContext' of type 'ApplicationDbContext'. The exception 'The entity type 'IdentityUserLogin<string>' requires a primary key to be defined.

(this used to work before restructuring)

i'm adding db context in Project.Web/Program.cs:
builder.Services.AddDbContext<ApplicationDbContext>(options =>
    options.UseNpgsql(
        builder.Configuration.GetConnectionString("ApplicationDbContext") ??
        throw new InvalidOperationException(
            "Connection string 'BlogContext' not found."
        )
    )
);


db context in Project.Infrastructure.Data:
namespace Project.Infrastructure.Data;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
    : IdentityDbContext<ApplicationUser>(options) {
    public DbSet<Post> Post { get; set; } = default!;
    public DbSet<TagPost> TagPost { get; set; } = default!;
    public DbSet<Comment> Comment { get; set; } = default!;

    public DbSet<Product> Product { get; set; } = default!;
    public DbSet<Category> Category { get; set; } = default!;
    public DbSet<CartItem> CartItem { get; set; }


and ApplicationUser in Project.Domain.Entities.Identity
public class ApplicationUser : IdentityUser {
    public ICollection<Post> Posts { get; } = [];
    public ICollection<Comment> Comment { get; } = [];
}


i've moved migration files to Project.Infrastructure/Data/Migrations
but now i can't do databtase update or make new migrations, or run the app
Was this page helpful?