🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Model Patterns
This page was created by Wikiadmin on 2026-07-29. Last edited by Wikiadmin on 2026-07-29.

Model patterns help you add established model structures to an MDriven solution, and are for developers who want to reuse architecture such as authentication, background work, translation, logging, or email handling.

A model pattern is a set of model elements that work together according to a recognized structure. In MDriven, a pattern can be supplied as a .modlr file that you merge into an empty or existing model. For example, the SysAsyncTicket pattern defines classes that MDrivenServer recognizes for background work.

Use a pattern from a model file

Use a model pattern when the supplied structure matches the behavior your application needs. Start with model examples that provide downloadable packages and instructions.

  1. Download the pattern's .modlr file.
  2. Open the model that you want to extend in MDriven Designer.
  3. Select Open Merge Add.
  4. Select the downloaded .modlr file.
  5. Review the imported packages, classes, ViewModels, actions, and assets before you adapt the pattern to your model.

For example, import the password-reset template when your Turnkey application uses the default ASPNETIdentity login package and you need reset-password pages and a server-side process that sends reset emails.

What happens during a merge

MDriven merges incoming content with existing content by name. This avoids duplicate model elements, but it also means that you must inspect a merge when your model already contains names used by the pattern.

Incoming content Merge behavior
Class with an existing class name The incoming class content is copied to your existing class. The incoming class is discarded to avoid a duplicate.
Package with an existing package name The incoming package content is moved into your existing package.
ViewModel with an existing ViewModel name The incoming ViewModel is skipped. New ViewModels are added.
Diagram with an existing diagram name The diagrams are merged to avoid duplicates.
AssetsTK content The incoming AssetsTK content is merged into your AssetsTK and can add or update assets.

For example, if your model already has a ViewModel named ResetPasswordPage, an incoming ViewModel with that name is skipped. Rename or reconcile the ViewModels before relying on the imported pattern.

Common model patterns

Authentication with SysUserAuthentication

The SysUserAuthentication pattern adds the SysSingleton and SysUser classes needed to enable login and authentication in Turnkey systems. Import it before you build application features that require a signed-in user.

Password reset

The password-reset template adds a reset-password page, a server-side ViewModel that runs every 20 seconds to send reset instructions, and a page where the user sets a password.

After import:

  1. Set the PasswordReset package's Default superclass if your model requires one.
  2. Configure an email server for Turnkey or MDrivenServer.
  3. Create an action that opens the RestetPasswordPage ViewModel.

The reset-password page must not have access groups. The set-password page also handles expired reset tickets and allows the user to request a new ticket.

Background work with SysAsyncTicket

SysAsyncTicket is a model pattern recognized by MDrivenServer. Use it when work should run in the background instead of during the user's request. For example, create an asynchronous ticket for a long-running operation and let MDrivenServer process it.

Localization and translation

A translation pattern stores translations for text in actions and ViewModels. OCL operators such as Translate can then translate data according to that model structure.

Turnkey trace log

Use the SysTurnkeyTraceLog pattern when you need to record user activity in a Turnkey application. For each navigation or action that can change data, MDrivenTurnkey snapshots information and spools objects of the trace-log class every 30 seconds.

Outgoing email queue

An outgoing email queue pattern adds queued and sent email handling to the standard base model. It includes a seeker for queued or sent emails, a detail view for changing queued emails, and two server-side ViewModels: one sends email and one cleans up sent email.

The pattern supports file attachments, exception handling, error viewing, and retrying failed sends.

Calendar dimensions

A calendar pattern provides classes for days, weeks, months, and years. Prepopulate these values when you need efficient grouping or aggregation. For example, associate an order with a calendar day, then aggregate orders by month for a report.

Adapt patterns to your model

A pattern supplies a starting structure; configure it for your domain. Keep the imported classes and ViewModels when they express the required behavior, and change names, inheritance, actions, and UI only after you understand the dependencies.

For example, the password-reset pattern requires an email server and an action that opens its reset ViewModel. Importing the model file alone does not make password reset available to users.

See also