-
Notifications
You must be signed in to change notification settings - Fork 49
Builder Modes
The models builder can be used in different modes:
- PureLive models
- Dll models
- AppData models
- API models
The mode is indicated by the Umbraco.ModelsBuilder.ModelsMode
key in the appSettings
section of the web.config
file.
Corresponds to the PureLive
setting value.
With PureLive models, models are generated and compiled on the fly, in memory, at runtime. They are available in views exclusively. This is for people who exclusively use the Umbraco back-end, and probably do not write controllers anyway. Whenever a content type is modified, models are re-generated without restarting Umbraco (in the same way .cshtml views are recompiled).
The generated code is visible in ~/App_Data/Models
** REST OF THIS PAGE IS WORK IN PROGRESS **
Corresponds to the Dll
and LiveDll
setting values.
With Dll models, models are generated in the ~/App_Data/Models
directory, then compiled into a Dll that is copied into ~/bin
, thus restarting the application. Models must be generated explicitely from the dashboard or the content type editor.
If there are some filename.cs files in ~/App_Data/Models, the models builder will parse them for instructions and compile them with the models (see documentation for configuring and extending models).
Corresponds to the AppData
and LiveAppData
setting values.
Requires that the Site Integration package is installed, either via NuGet or as an Umbraco package, and that App_Code models are enabled (see Site Integration Configuration).
With App_Code models, models must be explicitely generated via the Zbu.ModelsBuilder dashboard in the developer back-end section. When models generation is triggered, model files are created in the ~/App_Data/Models folder. Then, a ~/App_Code/build.models file is created or touched, in order to cause Umbraco to compile the model files. Each time models are generated, Umbraco restarts. Whenever a content type is modified, models must be manually generated.
If there are some filename.cs files in ~/App_Data/Models, the models builder will parse them for instructions (see Models Generation Configuration).
Requires that the Site Integration package is installed, either via NuGet or as an Umbraco package, and that Dll models are enabled (see Site Integration Configuration).
With Dll models, everything works as with App_Code models, but the ~/App_Code/build.models file is never generated. Instead, a DLL named after the models namespace is generated in ~/bin. Each time models are generated, Umbraco restarts. Whenever a content type is modified, models must be manually generated.
Requires that the Site Integration package is installed, either via NuGet or as an Umbraco package, and that App_Data models are enabled (see Site Integration Configuration).
With App_Data models, everything works as with App_Code models, but the ~/App_Code/build.models file is never generated. This means that models are never compiled. You need to explicitely copy those files to App_Code, or to your Visual Studio solution, for them to get compiled. This is the way to "just generate models".
When App_Code or Dll models are configured, and Live models are also configured, then everything works as with App_Code or Dll models, and in addition models are automatically re-generated every time a content type (or data type) is modified. Which restarts Umbraco. So you don't need to go and press the button, but Umbraco may keep restarting. Up to you.
Requires that the Site Integration package is installed, either via NuGet or as an Umbraco package, and that the API is enabled (see Site Integration Configuration). Requires that the Visual Studio Extension is installed.
Then you need to:
- Go to Tools | Options | Zbu | ModelsBuilder Options and configure the url to your website (eg http://www.example.com), and a logon and password for an Umbraco user that has permission to access the developer section.
- Create a folder in your solution -- pick your own name. Within that folder, create a CSharp file -- again, pick your own name. The file can contain code, or just be empty. Edit the properties of the file and set the Custom tool value to ZbuModelsBuilder. Save the file, or right-click and Run Custom Tool. New files should appear underneath the file.
If there are some filename.cs files in the models folder, the models builder will parse them for instructions (see Models Generation Configuration).
If you generate models in the main site project, where the Site Integration package is already installed, then that is all you need. If you generate models in a separate library project, you must reference some libraries by installing the Libraries project in order to build the models.