Service Startup
Service Startup executes logic when the application starts. Service Startup classes are automatically discovered and executed by the framework.
Create Service Startup
Create a new file in the project in the Logic or Startup folder.
Project / Startup / RoleStartup.cs
The ServiceStartup attribute takes the following parameters:
- StartupOperation:
Pre
executes before system records are created,Post
executes after (usePost
unless you needPre
) - Order (optional): Execution order when multiple startup services run at the same stage (lower executes first, default: 0)
StartupContext
Project / Startup / MyStartup.cs
Initialize Roles and Permissions
Use the SecurityBuilder to initialize roles and assign permissions. Roles are created if they don't exist. Permissions must already exist (automatically created by the framework for entities).
Project / Startup / RoleStartup.cs
Table permissions follow the convention TABLE_(TableName)_(Operation)_(Level)
. For example: TABLE_Widget_READ_SYSTEM
, TABLE_Account_UPDATE_TEAM
. See the Security documentation for more details.
Dependency Injection
Service Startup classes support constructor-based dependency injection: