An important question that will arise once you've decided to extend the metadata model is whether you need to fork the main repo or not. Use the diagram below to understand how to make this decision.

The green lines represent pathways that will lead to lesser friction for you to maintain your code long term. The red lines represent higher risk of conflicts in the future. We are working hard to move the majority of model extension use-cases to no-code / low-code pathways to ensure that you can extend the core metadata model without having to maintain a custom fork of DataHub.
We will refer to the two options as the **open-source fork** and **custom repository** approaches in the rest of the document below.
## This Guide
This guide will outline what the experience of adding a new Entity should look like through a real example of adding the
A key represents the fields that uniquely identify the entity. For those familiar with DataHub’s legacy architecture,
these fields were previously part of the Urn Java Class that was defined for each entity.
This struct will be used to generate a serialized string key, represented by an Urn. Each field in the key struct will
be converted into a single part of the Urn's tuple, in the order they are defined.
Let’s define a Key aspect for our new Dashboard entity.
```
namespace com.linkedin.metadata.key
/**
* Key for a Dashboard
*/
@Aspect = {
"name": "dashboardKey",
}
record DashboardKey {
/**
* The name of the dashboard tool such as looker, redash etc.
*/
@Searchable = {
...
}
dashboardTool: string
/**
* Unique id for the dashboard. This id should be globally unique for a dashboarding tool even when there are multiple deployments of it. As an example, dashboard URL could be used here for Looker such as 'looker.linkedin.com/dashboards/1234'
*/
dashboardId: string
}
```
The Urn representation of the Key shown above would be:
### <a name="step_2"></a>Step 2: Create the new entity with its key aspect
Create an Aspect union to define the key aspects an Entity is associated with. An aspect represents a related
record of metadata about an entity. Any record appearing in the Union should be annotated with @Aspect. In this example below, we take the DashboardKey aspect and the BrowsePaths aspect and include them in this `DashboardAspect` union. For all other aspects, we will utilize a much more flexible way of attaching aspects to entities using a `yaml` file.
```
namespace com.linkedin.metadata.aspect
import com.linkedin.metadata.key.DashboardKey
import com.linkedin.common.BrowsePaths
/**
* A union of all supported metadata aspects for a Dashboard
*/
typeref DashboardAspect = union[
DashboardKey,
BrowsePaths
]
```
The first aspect will be by convention the Entity’s key aspect.
Previously, you were required to add all aspects for the entity into this Aspect union. You will see examples of this pattern throughout the code-base (e.g. `DatasetAspect`, `DashboardAspect` etc.). This is no longer required.
### <a name="step_3"></a>Step 3: Define the Entity Snapshot
The snapshot describes the format of how an entity is serialized (as a single snapshot record) for read and write operations to DataHub's metadata service (f.k.a. GMS). All snapshots have two fields:
-`urn` of type `Urn`
-`snapshot` of type `union[Aspect1, Aspect2, ...]`.
The snapshot needs an `@Entity` annotation with the entity’s name. The name is used for specifying entity type when
At the beginning of this document, we walked you through a flow-chart that should help you decide whether you need to maintain a fork of the open source DataHub repo for your model extensions, or whether you can just use a model extension repository that can stay independent of the DataHub repo. Depending on what path you took, the place you store your aspect model files (the .pdl files) and the entity-registry files (the yaml file called `entity-registry.yaml` or `entity-registry.yml`) will vary.
- Open source Fork: Aspect files go under [`metadata-models`](../../metadata-models) module in the main repo, entity registry goes into [`metadata-models/src/main/resources/entity-registry.yml`](../../metadata-models/src/main/resources/entity-registry.yml). Read on for more details in [Step 6](#step_6).
- Custom repository: Read the [metadata-models-custom](../../metadata-models-custom/README.md) documentation to learn how to store and version your aspect models and registry.
Attaching non-key aspects to an entity can be done simply by adding them to the entity registry yaml file. The location of this file differs based on whether you are following the oss-fork path or the custom-repository path.
If you opted for the open-source fork approach, where you are editing models in the `metadata-models` repository of DataHub, you will need to re-build the DataHub metadata service using the steps below. If you are following the custom model repository approach, you just need to build your custom model repository and deploy it to a running metadata service instance to read and write metadata using your new model extensions.
Then, re-deploy metadata-service (gms), and mae-consumer and mce-consumer (optionally if you are running them unbundled). See [docker development](../../docker/README.md) for details on how
to deploy during development. This will allow Datahub to read and write Snapshots of your new entity or extensions to existing entities, along with serving search and graph queries for that entity type.
### <a name="step_8"></a>(Optional) Step 8: Extend the DataHub frontend to view your entity in GraphQL & React
If you are extending an entity with additional aspects, and you can use the auto-render specifications to automatically render these aspects to your satisfaction, you do not need to write any custom code.
However, if you want to write specific code to render your model extensions, or if you introduced a whole new entity and want to give it its own page, you will need to write custom React and Grapqhl code to view and mutate your entity in GraphQL or React. For
instructions on how to start extending the GraphQL graph, see [graphql docs](../../datahub-graphql-core/README.md). Once you’ve done that, you can follow the guide [here](../../datahub-web-react/README.md) to add your entity into the React UI.