> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/0.4.14/get-started/baking-code-generation.md).

# Baking and code generation

### Baking Video Tutorial

{% embed url="<https://www.youtube.com/watch?v=_AqX5UUBHzI&ab_channel=coherence>" %}

### Overview

Out of the box, **coherence** will use *C# Reflection* to sync all the data at runtime. This is a great way to get started but it is very costly performance-wise.

For optimal runtime performance, we need to **create a schema** and perform **code generation** specific to our project.&#x20;

**coherence** offers an automatic way of doing that called **baking.**

Learn more about this in the [How does coherence work](/0.4.14/overview/how-does-coherence-work.md) section.

### Bake schemas

<div align="left"><img src="/files/-MYvSuqFqSO0pjzPThcN" alt=""></div>

Click on `coherence -> Bake Schemas`.

This will go through all `CoherenceSync` components in the project and generate a schema file based on the selected variables, commands and other settings. It will also take into account any `CoherenceArchetype` components.

For every prefab with a `CoherenceSync` object, the baking process will generate a bespoke C# file in the `coherence/baked` folder in the project.&#x20;

Adding that file to the prefab will make that prefab use bespoke generated code instead of C# reflection.

### Activate baked schema on prefab

Once the Schema has been baked, you will be able to activate the baked script in the *Configuration* section of the CoherenceSync component.

![](/files/-Ma4iUSrlZG5lwhMwqm-)

The name of the baked script will be `CoherenceSync[prefabName]`.

![](/files/-MYvU4ONphLnSziyJAO-)

###
