dotnet-create-entity
Skill1 starsChanged todayMITView on GitHub
Create a domain entity in a .NET module with a validating factory, private setters, domain errors and its EF Core configuration (tenant-scoped when the repo is multi-tenant). Use when adding a new aggregate or entity to a module's Domain layer.
In this repository84 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/angular-coding-style.mdcCursor rule
- .cursor/rules/angular-patterns.mdcCursor rule
- .cursor/rules/angular-security.mdcCursor rule
- .cursor/rules/angular-testing.mdcCursor rule
- .cursor/rules/common-code-review.mdcCursor rule
- .cursor/rules/common-coding-style.mdcCursor rule
- .cursor/rules/common-development-workflow.mdcCursor rule
- .cursor/rules/common-security.mdcCursor rule
- .cursor/rules/common-testing.mdcCursor rule
- .cursor/rules/csharp-coding-style.mdcCursor rule
- .cursor/rules/csharp-data-access.mdcCursor rule
- .cursor/rules/csharp-patterns.mdcCursor rule
- .cursor/rules/csharp-security.mdcCursor rule
- .cursor/rules/csharp-testing.mdcCursor rule
- .cursor/rules/design-design-system.mdcCursor rule
- .cursor/rules/project-backend.mdcCursor rule
- .cursor/rules/project-security.mdcCursor rule
- .cursor/rules/project-testing.mdcCursor rule
- .cursor/rules/project-web.mdcCursor rule
- .cursor/rules/typescript-coding-style.mdcCursor rule
- .cursor/rules/typescript-patterns.mdcCursor rule
- .cursor/rules/typescript-security.mdcCursor rule
- .cursor/rules/typescript-testing.mdcCursor rule
- angular-guideSkill
- break-uiSkill
- dotnet-create-command-querySkill
- dotnet-create-moduleSkill
- dotnet-ef-migrationSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- ui-ux-pro-maxSkill
- angular-guideSkill
- break-uiSkill
- dotnet-create-command-querySkill
- dotnet-create-entitySkill
- dotnet-create-moduleSkill
- dotnet-ef-migrationSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Test first: write the domain tests for Create and each state method (success and every error) before the code.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a domain entity
Inputs: entity name (PascalCase), module. Before writing, read one existing entity, its <Entity>Errors and its
configuration in the same module and follow them exactly (base class, id type, public id, tenant marker, Error
factory names). The templates below are the default shape only.
Test first: write the domain tests for Create and each state method (success and every error) before the code.
Files
src/Modules/<Module>/<Module>.Domain/<Entity>.cs
src/Modules/<Module>/<Module>.Domain/<Entity>Errors.cs
src/Modules/<Module>/<Module>.Infrastructure/Database/Configurations/<Entity>Configuration.cs
tests/<Module>.Tests/Domain/<Entity>Tests.csEntity
namespace <Module>.Domain;
public sealed class <Entity> : TenantEntity // the repo's base: BaseEntity<TKey>, AuditableEntity, tenant entity...
{
private <Entity>() { } // for EF Core
public string Name { get; private set; } = null!;
public <Entity>Status Status { get; private set; }
public static Result<<Entity>> Create(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
return Result.Failure<<Entity>>(<Entity>Errors.NameRequired);
}
if (name.Length > MaxNameLength)
{
return Result.Failure<<Entity>>(<Entity>Errors.NameTooLong);
}
return new <Entity> { Name = name.Trim(), Status = <Entity>Status.Draft };
}
public Result Archive()
{
if (Status == <Entity>Status.Archived)
{
return Result.Failure(<Entity>Errors.AlreadyArchived);
}
Status = <Entity>Status.Archived;
return Result.Success();
}
public const int MaxNameLength = 200;
}
public enum <Entity>Status
{
Draft,
Active,
Archived,
}Rules: private setters; collections exposed as IReadOnlyList<T> over a private list; state changes only through
methods that return Result; raise domain events inside the entity (RaiseDomainEvent(...)) when other modules
must react; the tenant id is set by the infrastructure (or passed to Create), never from request input.
Errors
namespace <Module>.Domain;
public static class <Entity>Errors
{
public static readonly Error NotFound = Error.NotFound("<Entity>.NotFound", "The <entity> was not found.");
public static readonly Error NameRequired = Error.Validation("<Entity>.NameRequired", "Name is required.");
public static readonly Error NameTooLong = Error.Validation("<Entity>.NameTooLong", "Name is too long.");
public static readonly Error AlreadyArchived = Error.Conflict("<Entity>.AlreadyArchived", "The <entity> is already archived.");
public static Error DuplicateName(string name) =>
Error.Conflict("<Entity>.DuplicateName", $"A <entity> named '{name}' already exists.");
}Business-rule failures are Validation/Problem, NotFound, Conflict or Forbidden; never Failure (500).
EF Core configuration
namespace <Module>.Infrastructure.Database.Configurations;
internal sealed class <Entity>Configuration : IEntityTypeConfiguration<<Entity>>
{
public void Configure(EntityTypeBuilder<<Entity>> builder)
{
builder.HasKey(e => e.Id);
builder.Property(e => e.Name).HasMaxLength(<Entity>.MaxNameLength).IsRequired();
builder.Property(e => e.Status).HasConversion<string>().HasMaxLength(50);
builder.HasIndex(e => new { e.TenantId, e.Name }).IsUnique(); // tenant column first when tenant-scoped
}
}The table goes in the module's schema (the context's default schema). Add the DbSet to the module context, then
create the migration with the dotnet-ef-migration skill.
Checklist
- Tests for
Createand every state method, written first - Private constructor, private setters, factory returning
Result<T> - Every failure has a typed
Errorwith code<Entity>.<Reason> - Configuration with lengths, conversions, tenant-first indexes
DbSetadded and migration generated
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

