Getting Started

Understanding Metadata

Learn how to describe your application structure in metadata. From simple entities to complex relationships, see how MetaFirst transforms metadata into production-ready code.

1. The Simplest Example – A Minimal Entity

A single entity with only a primary key and a name. MetaFirst already generates database, services, WebAPI, and Admin UI from this.

EntityFieldTypeAttributes
ToDoListIdintKey, Generated, SurrogateKey, DefVal=0, TestVal=1, Name=Name, Doc=Unique ToDoList Id|Primary key, AdminTheme=DataTables_Kai
ToDoListNamestringIsUnique, MaxLength=100, DefVal=, TestVal=ToDoListTestName, Doc=Unique todo list name

Understanding the Structure

Entity:Corresponds to a Database Table. Optional: change the table name with DbTableName=[AnotherTableName]
Field:Also called "Property", corresponds to a Database column
Type:The data type of the field/property. Optional: override with HasColumnType
Attributes:Meta-Attributes about the Property. Entity-wide attributes are set in the Key Property

Key Attributes Explained

FieldAttributeDescription
IdKeyDefines the Field as the (only) Primary key. Supported types: int, long, Guid, string
IdGeneratedMust be set for Surrogate keys and Guid keys
IdSurrogateKeySpecifies that the Key is database generated. This is the recommended setting. Types: int or long
IdDefVal=0Default value required for every property. Used in code for object construction. Use DbDefVal for database defaults
IdTestVal=1Mandatory for properties. Used for automatically generating xUnit tests
IdName=NameDefines the Property used for better naming. "MyTodoListInOctober" is clearer than an ID number
IdDoc=...Description of the entity. Used in code documentation
IdAdminThemeCurrently mandatory for the first Entity. Choose your Admin theme (more themes coming)
NameIsUniqueEnsures uniqueness. Creates database index for faster queries. Throws exception on duplicates
NameMaxLengthMax length for string properties. Creates nvarchar(MaxLength) unless overridden by HasColumnType

2. Activatable – Lifecycle Control

Activatable entities can be enabled or disabled without deleting data. MetaFirst generates filtering logic, UI toggles, and API behavior automatically.

EntityFieldTypeAttributes
ToDoListIdintKey, Generated, SurrogateKey, Activatable, DefVal=0, TestVal=1, Name=Name, Doc=Unique ToDoList Id|Primary key, AdminTheme=DataTables_Kai
ToDoListNamestringIsUnique, MaxLength=100, DefVal=, TestVal=ToDoListTestName, Doc=Unique todo list name
ToDoListActiveboolDefVal=false, TestVal=true, Doc=If data is activated

3. Audit – Tracking Data Changes

Audit fields track who created or modified data and when. Ideal for enterprise systems and compliance requirements.

EntityFieldTypeAttributes
ToDoListIdintKey, Generated, SurrogateKey, Audit, DefVal=0, TestVal=1, Name=Name, Doc=Unique ToDoList Id|Primary key, AdminTheme=DataTables_Kai
ToDoListNamestringIsUnique, MaxLength=100, DefVal=, TestVal=ToDoListTestName, Doc=Unique todo list name
ToDoListCreatedBystringMaxLength=100, DefVal=, TestVal=UnitTest, Doc=Data created by
ToDoListCreatedDateDateTimeFeFormat=yyyy-MM-ddTHH:mm:ss, DefVal=1900-01-01T00:00:00, TestVal=1900-01-01T00:00:00, Doc=Data creation date
ToDoListModifiedBystringMaxLength=100, DefVal=, TestVal=UnitTest, Doc=Data modified by
ToDoListModifiedDateDateTimeFeFormat=yyyy-MM-ddTHH:mm:ss, DefVal=1900-01-01T00:00:00, TestVal=1900-01-01T00:00:00, Doc=Data modification date

New Attribute: FeFormat

FeFormat defines the DateTime format for the Property. The database stores it as DateTime by default, or by a specific HasColumnType you define.

This format is especially important when exporting or importing data. When no format is specified, "1900-01-01T00:00:00" is used (ISO 8601 format).

4. Extendable / EAV – Dynamic Metadata

Extendable entities support dynamic properties using the EAV (Entity-Attribute-Value) model. MetaFirst hides all EAV complexity from client code.

EntityFieldTypeAttributes
ToDoListIdintKey, Generated, SurrogateKey, Extendable, DefVal=0, TestVal=1, AttributeStore=TodoListAttribute, Name=Name, Doc=Unique ToDoList Id|Primary key, AdminTheme=DataTables_Kai
ToDoListNamestringIsUnique, MaxLength=100, DefVal=, TestVal=ToDoListTestName, Doc=Unique todo list name
ToDoListAttribSchemastringMaxLength=100, DefVal=None, TestVal=ToDoList_Extended, Options=None|ToDoList_Extended, Doc=ToDoList schema
ToDoListDescriptionstringMaxLength=4000, AttribOf=ToDoList_Extended, AttribStoring=Big, DefVal=, TestVal=About the ToDoList, Doc=ToDoList detailed description

EAV-Specific Attributes

FieldAttributeDescription
IdAttributeStoreDefines the table where EAV data is stored. Every store has a normal and a "Big" table with the same structure, only the Value field is larger in the Big table
AttribSchemaOptionsRequired for Extendable/EAV Entities. Defines all possible EAV-Schemas for the data item. Users can select a schema in the Admin for every new data item
DescriptionAttribOfSpecifies which schema this attribute belongs to. When "None" is specified, the data has no additional Schema Properties
DescriptionAttribStoringDefine the Small or Big store for the EAV-Attribute data

5. Basic Relation – One-To-Many

A ToDoList can contain multiple ToDoItems. MetaFirst automatically generates foreign keys, navigation properties, optimized queries, API endpoints, and related Admin UI views.

EntityFieldTypeAttributes
Parent Entity: ToDoList
ToDoListIdintKey, Generated, SurrogateKey, DefVal=0, TestVal=1, Name=Name, Doc=Unique ToDoList Id|Primary key, AdminTheme=DataTables_Kai
ToDoListNamestringIsUnique, MaxLength=100, DefVal=, TestVal=Todos in October, Doc=Unique todo list name
Child Entity: ToDoItem
ToDoItemIdintKey, Generated, SurrogateKey, DefVal=0, TestVal=1, Name=Id, Doc=Unique ToDoItem Id|Primary key
ToDoItemToDoListIdintForeignKey, DefVal=0, TestVal=1, Doc=Reference to parent ToDoList
ToDoItemTitlestringMaxLength=200, DefVal=, TestVal=Buy groceries, Doc=Item title
ToDoItemIsCompletedboolDefVal=false, TestVal=false, Doc=Completion status

Foreign Key Attribute

The ForeignKey attribute creates a relationship between entities. MetaFirst automatically:

  • Generates database foreign key constraints
  • Creates navigation properties in C# models
  • Builds optimized LINQ queries with proper joins
  • Generates API endpoints that respect relationships
  • Creates Admin UI views showing parent-child relationships

Ready to try it yourself?

Download the free Education Edition and start generating your own metadata-driven applications. For complete details on all attributes and advanced features, check out the full documentation.