Repository navigation
11 Generate Early Bound Types
flowline generate produces early-bound C# types for your solution's entities, option sets, and
Custom APIs, and puts them in Plugins/Models/ ready to use in your plugin code.
- After
cloneorinit, to get types before writing any plugin code - When entities or Custom APIs change in Dataverse and you want updated classes
- On a new dev machine after cloning the repo
flowline generate # reads solution from .flowline
flowline generate --solution-name ContosoSales # optional: must match the configured solution's UniqueName (case-insensitive), errors on mismatchOutput lands in Plugins/Models/:
Models/
├── Entities/ # one .cs file per entity (account.cs, contact.cs, …)
├── Messages/ # one .cs file per Custom API
├── OptionSets/ # option set enumerations
└── EntityOptionSetEnum.cs # OptionSet helper
└── XrmContext.cs # OrganizationServiceContext for LINQ queries
You get only the entities and Custom APIs in your solution, plus any extra tables.
Note:
Models/is overwritten on each run. If you have uncommitted changes there, Flowline warns before proceeding. Commit or discard them first.
For a dedicated models project, pass --output once. It's saved to .flowline:
flowline generate --output ../ContosoSales.Models/ModelsOn the first run, Flowline derives the namespace from your .csproj assembly name and saves it
to .flowline. Later runs reuse the saved value, so no flag is needed.
To override:
flowline generate --namespace Contoso.Plugins.ModelsThe new namespace is saved to .flowline and used for all future runs.
Your plugins often reference standard tables (account, contact) that are not part of your
solution. Add them with --extra-tables:
flowline generate --extra-tables account,contact,systemuserThe list is saved to .flowline and merged with your solution's own entities on every run.
Passing --extra-tables again replaces the saved list.
generate works without a .flowline project file. Inputs are provided explicitly (see 02-Project-Configuration#project-mode-and-standalone-mode):
flowline generate --solution-name ContosoSales -o ./Models
flowline generate --solution-name ContosoSales --env https://contoso.crm4.dynamics.com -o ./ModelsWithout --env, the target is the environment of your currently active resource-specific PAC auth profile. A universal profile carries no environment URL, so pass --env when one is active.
The namespace defaults to ContosoSales.Models. Use --namespace to override.
Settings are not saved in standalone mode.
Flowline supports multiple generators via --generator. The value is saved to .flowline.
| Flag | Backing tool | Output style | Platform |
|---|---|---|---|
pac (default)
|
pac modelbuilder build |
Microsoft-style (lowercase filenames, OptionSetValue) |
Cross-platform |
xrmcontext |
XrmContext v4 dotnet tool (preview, not released yet) | Modern C# with typed enums, ServiceContext, PascalCase |
Cross-platform |
xrmcontext3 |
Delegate.XrmContext v3 F# exe | Same quality as xrmcontext but Windows-only |
Windows only |
ebg |
Early Bound Generator V2 in-process | PascalCase, typed enums, ServiceContext, one file per entity |
Cross-platform |
flowline generate --generator xrmcontextebg runs Daryl LaBar's Early Bound Generator inside Flowline. No separate install, and no DLLs
to copy into your PAC installation.
flowline generate --generator ebgFlowline sets the namespace, output folder, service context name and the entity and message
filters from what your solution actually contains. To reach EBG's other settings, put a
builderSettings.json at your project root. Flowline overwrites only the keys it derives and keeps
the rest.
ebg needs no extra sign-in.
xrmcontext auth: Flowline picks up your PAC auth profile automatically. Personal account profiles
open a browser once, then the token is cached for later runs. Service principal profiles need
the client secret separately, via --client-secret or the AZURE_CLIENT_SECRET env var.
flowline generate --generator xrmcontext --client-secret <your-secret>Flowline runs XrmContext without a global install. You can install it globally with dotnet tool install -g XrmContext if you want to run it directly.
xrmcontext3 auth: same PAC auth profile behaviour as xrmcontext, a browser for personal
accounts and --client-secret for service principals. Windows only; use xrmcontext for new projects.
Required NuGet package: Generated code references
System.ComponentModel.DataAnnotations. Add it to your plugin project or it won't compile:dotnet add Plugins/ContosoSales.Plugins.csproj package System.ComponentModel.Annotations
Use --client-id to override the application ID from the PAC auth profile when needed:
flowline generate --generator xrmcontext --client-id <app-id> --client-secret <secret>→ Full auth details and CI/CD setup: 03-Authentication