Skip to main content
A condensed reference for adding a new EF Core entity. For the full walkthrough including commands, queries, and frontend, see Adding a Feature.

Checklist

1

Create the entity class in Domain

Interfaces to implement:
  • BaseEntity — provides Id (Guid)
  • ITenantScopedEntity — requires TenantId property; enables global query filter
  • IAuditableEntity — requires CreatedAt and UpdatedAt; automatically set by SaveChangesAsync
Not tenant-scoped? If the entity belongs to a user rather than a tenant (e.g., user profile data), implement IUserScopedEntity instead and filter by UserId.
2

Create the EF Core configuration

3

Register the configuration in ApplicationDbContext

4

Add to IApplicationDbContext interface

5

Create and apply the migration

Verify the migration was applied:

Common mistakes

Forgetting the global query filter — if you omit HasQueryFilter, queries return records from all tenants. No error occurs; data leaks silently. Always add the filter for tenant-scoped entities. Forgetting to register the configuration — if you create TagConfiguration but do not call ApplyConfiguration in OnModelCreating, the entity uses EF Core’s conventions and has no filter, no unique index, and no cascade delete. Creating the migration before adding DbSet — EF Core discovers entities through DbSet properties. If DbSet<Tag> is missing, the migration will not include the table. Add the DbSet first. Using int for primary keys — AspFox uses Guid PKs throughout. Using int breaks the BaseEntity contract and makes the admin panel and audit log behave unexpectedly.