Jump to Section
Introduction to Storing Custom Configurations in Umbraco#
As a developer, you have probably encountered a situation in which you had to store a setting in the database.
In such a situation, an additional table is required.
Of course, you can connect to the database on each environment and create a new table using a basic script.
If you want to do it more elegantly, you need to create a migration so the table will be created automatically if it is missing during the Umbraco startup.
This requires additional work, which could be time-consuming.
Leveraging Existing Tables for Custom Configurations#
Happily, there is a way to store a simple configuration values in the existing umbracoKeyValue table.
This table consists of three columns: key, value, and updated.

Umbraco umbracoKeyValue table in SQL Server Management Studio view
Please be aware that the value column is of type nvarchar(255), so it has some limitations.
Efficiently Using the umbracoKeyValue Table for Settings#
Of course, we can use existing KeyValue class and store new rows as below:
Simplifying the Process with IKeyValueService#
However, an API is available, and we don't need to inject IScopeProvider to access the Umbraco database.
All we need to do is inject the available IKeyValueService.
Then, we can use the existing SetValue method as below:
To retrieve an existing value, we just need to use other available method:
We can find other interesting methods which could be useful in some scenarios. Here is a full list of methods:
Optimizing Your Umbraco Configuration Storage Strategy#
As you can see, whenever you need to store a simple configuration in the database, you should definitely consider using the IKeyValueService to minimize the effort required.
What's next?#
🌐 Explore More: Interested in learning about Umbraco, .NET, and other web development insights? Explore our blog for a wealth of information and expert advice.
✉️Get in Touch: If you have questions or need assistance with your Umbraco projects, don't hesitate to contact us. Our team of experts is always ready to help you navigate any challenges and optimize your digital solutions.