| name | generate-ids |
| description | Generate DataverseUnitTest Id<T> definitions using the Id Generator CLI. Use when writing or updating unit tests that need Id<>, nested *Ids classes, or test entity GUIDs for Dynamics/Dataverse. |
Generate DataverseUnitTest IDs
Use the Id Generator CLI instead of hand-writing GUIDs or guessing naming rules.
Documentation: Id Generator wiki · Id Generator CLI wiki
Install (NuGet)
dotnet tool install -g DataverseUnitTest.IdGenerator.Cli
NuGet: DataverseUnitTest.IdGenerator.Cli
Requires .NET 10 SDK or runtime (or newer).
When to use
- Adding or extending test classes with
Id<T> properties
- Creating nested
*Ids helper classes for test data
- Regenerating GUIDs while preserving existing structure
Preferred command
If the global tool is installed from NuGet:
idgen --settings-file .cursor/IdGeneratorSettings.json --input "Account 2|Contact"
When working in the source repository without the global tool:
dotnet run --project IdGenerator.Cli -- --settings-file .cursor/IdGeneratorSettings.json "Account 2|Contact"
Input format
Each non-empty line defines IDs for one Early Bound entity type. On the command line, use | instead of a newline.
Examples:
Account
Account 2
Acme_ProjectTask,Task
Contact,Partners,Jim,Bob
Account 2|Contact,Partners,Jim,Bob
Rules:
- First token is the entity type (
Account, Contact, Acme_Project, etc.)
- Space format:
<EntityType> [Count]
- Comma format:
<EntityType>,<NameOrCollection>[,<IdName1>,...]
- Do not put spaces after commas inside comma-based tokens
Modes
Generate from entity input
idgen --settings-file .cursor/IdGeneratorSettings.json --input "Account|Contact 2"
Regenerate from existing C#
Parse an existing test ID block and regenerate GUIDs with the same shape:
idgen --settings-file .cursor/IdGeneratorSettings.json --from-csharp TestExample.TestMethodNameClass.TestIds path/to/TestFile.cs
Or from stdin:
Get-Content path/to/snippet.cs | idgen --settings-file .cursor/IdGeneratorSettings.json --from-csharp TestExample.TestMethodNameClass.TestIds -
Deterministic output
Use --seed when reproducible GUIDs are useful (docs, examples, snapshots):
idgen --seed 42 --settings-file .cursor/IdGeneratorSettings.json --input "Account 2"
Without --seed, GUIDs are random (normal test usage).
Settings
Default project settings live at .cursor/IdGeneratorSettings.json:
useClassIds: true — nested *Ids classes (current test style)
useTargetTypedNew: true — new("GUID") syntax
Override on the command line when needed:
--use-struct-ids
--use-explicit-new
Workflow
- Identify entities needed for the test.
- Build entity input (use
| on one line for CLI convenience).
- Run
idgen and capture stdout.
- Paste the generated properties/classes into the test's nested IDs helper class.
- Do not invent GUIDs or naming conventions manually.
Match existing test patterns such as nested TestIdsClass / *Ids containers in the test project.
Update the global tool
dotnet tool update -g DataverseUnitTest.IdGenerator.Cli