Ontology Plugin For Visual Studio
To edit the datamodel of a Relatude Website you must install our Visual Studio plugin:
Download VS Ontology plugin (latest version)
The datamodel is stored in an xml text file called “content.definition”. To edit the datamodel simply double click the file in Visual Studio and the plugin will open the editor:
When you edit the datamodel and make changes, they are stored in the content.definition file. This is the master file of the datamodel. The code files and database tables are generated from this file.
Everytime you save, the plugin will update the code files and the Relatude runtime will update the database when you start the website. To make a change, simply save in Visual Studio and refresh the site in the browser.
About the code generation
The code generation is by default activated on every save. The code generation is a script and you find it under the script folder inside the editor. If you open it you can see options to set when the generation is activated. There are also options to add your own code generations scripts for building your own testing code, poco objects, view models etc. The script language is python for .Net and you have access to the internal script. Just copy and paste it to make your own script.
About the database update
The Relatude runtime (the WAF.dll running in the website process) will automatically create, rename or delete the tables necessary to make the database fit the datamodel. This allows you to simply publish your code to the server and Relatude will automatically update the database as the website starts. You can also restore and older database backup and Relatude will make sure this database has all the necessary fields to start. (Deleted fields or tables are not actually deleted, but renamed to “xxx___deleted” in case you connect an old datamodel to a newer database)
Working with the definition file
Every time you click save, the content.definition file in the root is updated. It is this file that is loaded when Relatude starts up. You may operate with different definition files in your projects and call them what you want as long as they end with “.definition”. The last file you save will be the active datamodel. This is useful in case you just want to try out something while keeping a copy of the original definition. Simply copy the definition file and try out your new changes in the copy and open the old one if you want to go back to the original datamodel.
Create new content class
To create a new content class:
- Double click on the content definition file in the solution explorer to open the ontology plugin
- Right click on the "Content classes" folder in the ontology plugin
- Select the type of content class. Select "ContentClass" type for normal content classes. InnerContentClass must be used for classes that are used with an InnerContent property.
- Give the content class a codename.
Add a simple property
After the content class has been create, you will see something like the screenshot above. To add a property, click on the "Plus" icon marked in red in the screenshot.
That opens the following dialogue, where you select the type of property:
To understand the different property types, see the documentation for the property types.
For now, we create a simple ShortString property called SubHeading:
In most cases, you don't need to make any changes to the settings for the property. The exception is enumerations and relation properties.
Create a relation property
To create a relation property, you first need to create a relation. Right click on the Relations folder in the plugin as shown to the left.
There are usually 5 things to add to the relation that is created:
- A name for the relation. We suggest that you use the names of the related classes, and plural to show what kind of relation it is.
- The namespace to use for the generated class
- Relation type: One to many or Many to many.
- Children class
- Parents class
The next step is to create the relation properties on the classes. There are 3 relevant relation property types:
- Content Children
- Content Parent
- Content Parents
If you have a one to many relation, you must create a Content Parent property on the child content class and a Content Children property on the parent content class.
If you have a many to many relation, you must create a Content Parents property on the child content class, and a Content Chilkdren property on the parent content class.
When you create a relation property, you must specify the Relation it uses.
1. Activate the Relation setting (it turns blue)
2. Select the relation class you created earlier.
3. Save the definition, and the required code is generated.