Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MPR File Format

Mendix projects are stored in .mpr files, which are SQLite databases containing BSON-encoded model elements. This page provides an overview of the format; see v1 vs v2 for version-specific details.

Structure

An MPR file is a standard SQLite database with two key tables:

Unit Table

The Unit table stores document metadata:

ColumnDescription
UnitIDBinary UUID identifying the document
ContainerIDParent module UUID
ContainmentNameRelationship name (e.g., documents)
UnitTypeFully qualified type name
NameDocument name

UnitContents Table (v1 only)

In MPR v1, the UnitContents table stores the actual BSON document content:

ColumnDescription
UnitIDBinary UUID matching the Unit table
ContentsBSON blob containing the full document

In MPR v2, document contents are stored as individual files in the mprcontents/ folder instead.

Unit Types

Every document in a Mendix project has a unit type:

UnitTypeDocument Type
DomainModels$DomainModelDomain model (entities, associations)
DomainModels$ViewEntitySourceDocumentOQL query for VIEW entities
Microflows$MicroflowMicroflow definition
Microflows$NanoflowNanoflow definition
Pages$PagePage definition
Pages$LayoutLayout definition
Pages$SnippetSnippet definition
Pages$BuildingBlockBuilding block definition
Enumerations$EnumerationEnumeration definition
JavaActions$JavaActionJava action definition
Security$ProjectSecurityProject security settings
Security$ModuleSecurityModule security settings
Navigation$NavigationDocumentNavigation profile
Settings$ProjectSettingsProject settings
BusinessEvents$BusinessEventServiceBusiness event service

BSON Document Structure

Every BSON document contains at minimum:

FieldTypeDescription
$IDBinary (UUID)Unique identifier for this element
$TypeStringFully qualified type name (using storageName, not qualifiedName)

ID Format

IDs are stored as BSON Binary subtype 0 (generic) containing UUID bytes:

{
  "$ID": {
    "Subtype": 0,
    "Data": "base64-encoded-uuid"
  }
}

Array Convention

Arrays in Mendix BSON have an integer count as the first element:

{
  "Attributes": [
    3,              // Count/type prefix
    { ... },        // First attribute
    { ... }         // Second attribute
  ]
}

The prefix value (typically 2 or 3) indicates the array type. When writing arrays, you must include this prefix. When parsing, skip the first element.

Reference Types

Reference TypeStorage FormatExample
BY_ID_REFERENCEBinary UUIDIndex AttributePointer
BY_NAME_REFERENCEQualified name stringValidationRule Attribute
PARTEmbedded BSON objectChild objects serialized inline

Using the wrong reference format causes Studio Pro to fail loading the model. Always check the metamodel reflection data to determine which format each property uses.

Storage Names vs Qualified Names

The $Type field in BSON must use the storageName, not the qualifiedName. These are often identical but not always:

qualifiedName (SDK)storageName (BSON $Type)
DomainModels$EntityDomainModels$EntityImpl
DomainModels$IndexDomainModels$EntityIndex

Using the wrong name causes TypeCacheUnknownTypeException when opening in Studio Pro. See Storage Names for more details.