Create a custom model
This topic describes how to define a custom model.
Define custom facets and events
Define custom facets and events
To create custom facets and events:
-
Create a new project - for example,
Documentation.Model. -
Define facets and events.
NoteEnsure that all properties adhere to xConnect’ type restrictions. Decorate any facet used in the tracker with the
[Serializable]attribute.
Create a model
Create a model
To create a model:
-
Create a class named
CollectionModel- for example,Documentation.Model.CollectionModel. Create an instance of theXdbModelBuilderas shown:NoteThe model’s full name (represented by the
FullNameproperty of theXdbModelclass) includes the model’s name and version. For example:DocumentationModel,1.0. -
Optionally, reference another model that you want to use. In the following example, the
Sitecore.XConnect.Collection.Model.CollectionModel.Modelis referenced. Classes such asFacetandEventare included automatically. -
Define the
FrequentFlyerInfocontact facet and theBoardFlightevent: -
If facets, events, or types inherit a type that is located in a different assembly, use the
modelbuilder.RegisterType()method to manually register a type. For example,Documentation.Model.FrequentFlyerInfomight inheritCommon.Model.InheritedBase.
In order to use your model you must deploy your custom model to xConnect, the Marketing Automation Engine, and all core Sitecore instances.