A model is the definition of everything Invantive Control for Excel needs to exchange data between an Excel workbook and the connected platforms. The model is stored inside the workbook in a hidden [[Invantive Control for Excel/Repository/Repository|repository]] and travels with the file: a model user who opens the workbook needs no separate installation of the model, only Invantive Control for Excel and access to the facts database.
A model consists of:
- one or more [[Invantive Control for Excel/Concepts/Block|blocks]];
- zero or more [[Invantive Control for Excel/Concepts/Parameter|parameters]];
- zero or more [[Invantive Control for Excel/Concepts/Extension|extensions]];
- model-wide settings and metadata.
## Metadata
Each model carries metadata that can be queried from Excel formulas (see the `I_MDL_*` formulas in [[Invantive Control for Excel/Formulas/Formulas|Formulas]]):
- code, name and version (`mdl_code`, `mdl_name`, `mdl_version`);
- author, company and copyright;
- description, instructions and comments;
- dates of last open, last download and last upload, plus the user who performed them;
- the connection (database profile) last used.
## Model-wide Settings
- **Revision mode** (`mdl_revision_mode`): controls whether revisions of the model are recorded. Revisions register who changed the model, when and why.
- **Allow changes outside blocks** (`mdl_allow_changes_outside_blocks_flag`): when disabled, the model user can only edit cells inside blocks; the rest of the workbook is protected.
- **Password protection**: the model definition can be protected with a password so only authorised modelers can open the model editor.
## Model Events
A model can execute an [[Invantive Control for Excel/Concepts/Extension|extension]] at defined moments in its life cycle:
| Event | Moment |
| --- | --- |
| `mdl_on_after_open_workbook` | after the workbook is opened |
| `mdl_on_after_connect_database` | after a database connection is established |
| `mdl_on_after_partition_change` | after the selected partitions change |
| `mdl_on_before_sync` / `mdl_on_after_sync` | around a full synchronisation |
| `mdl_on_before_download` / `mdl_on_after_download` | around a download |
| `mdl_on_before_upload` / `mdl_on_after_upload` | around an upload |
| `mdl_on_before_close_workbook` | before the workbook closes |
## Model Licence
Use of a specific model can itself be licensed, independent of the Invantive Control licence: a model can carry a licence window (`mdl_license_start_date`, `mdl_license_end_date`) and can be bound to specific machines or installation identifiers (`mdl_license_pattern_*`). This allows a modeler to distribute a model commercially or restrict use to specific devices.